{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "26bb937f",
   "metadata": {},
   "source": [
    "# 导入模块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3bc3846c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from pyecharts.charts import Map\n",
    "from pyecharts.charts import Bar\n",
    "from pyecharts.charts import Line\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Pie\n",
    "from pyecharts.commons.utils import JsCode"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f76dbf09",
   "metadata": {},
   "source": [
    "# 老年人口"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a0a8fb0f",
   "metadata": {},
   "source": [
    "## 老年人口不同地区分布（全国）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "25586ecb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>地区</th>\n",
       "      <th>合计</th>\n",
       "      <th>小计</th>\n",
       "      <th>单身老人户</th>\n",
       "      <th>一个老年人与未成年的亲属户</th>\n",
       "      <th>其他</th>\n",
       "      <th>小计.1</th>\n",
       "      <th>只有一对老夫妇的户</th>\n",
       "      <th>一对老夫妇与未成年的亲属户</th>\n",
       "      <th>其他.1</th>\n",
       "      <th>有三个65岁及以上老年人的户</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>山东</td>\n",
       "      <td>6746757</td>\n",
       "      <td>4284534</td>\n",
       "      <td>1490848</td>\n",
       "      <td>23741</td>\n",
       "      <td>2769945</td>\n",
       "      <td>2432541</td>\n",
       "      <td>1572344</td>\n",
       "      <td>27870</td>\n",
       "      <td>832327</td>\n",
       "      <td>29682</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>四川</td>\n",
       "      <td>6710282</td>\n",
       "      <td>4772272</td>\n",
       "      <td>1106491</td>\n",
       "      <td>113482</td>\n",
       "      <td>3552299</td>\n",
       "      <td>1912887</td>\n",
       "      <td>804349</td>\n",
       "      <td>84095</td>\n",
       "      <td>1024443</td>\n",
       "      <td>25123</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>江苏</td>\n",
       "      <td>6147499</td>\n",
       "      <td>3888399</td>\n",
       "      <td>1062588</td>\n",
       "      <td>35712</td>\n",
       "      <td>2790099</td>\n",
       "      <td>2223808</td>\n",
       "      <td>1129456</td>\n",
       "      <td>41957</td>\n",
       "      <td>1052395</td>\n",
       "      <td>35292</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>河南</td>\n",
       "      <td>5754338</td>\n",
       "      <td>3782040</td>\n",
       "      <td>826922</td>\n",
       "      <td>77762</td>\n",
       "      <td>2877356</td>\n",
       "      <td>1939986</td>\n",
       "      <td>860915</td>\n",
       "      <td>78609</td>\n",
       "      <td>1000462</td>\n",
       "      <td>32312</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>广东</td>\n",
       "      <td>5377567</td>\n",
       "      <td>3893992</td>\n",
       "      <td>802212</td>\n",
       "      <td>84397</td>\n",
       "      <td>3007383</td>\n",
       "      <td>1461232</td>\n",
       "      <td>447449</td>\n",
       "      <td>59839</td>\n",
       "      <td>953944</td>\n",
       "      <td>22343</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>湖南</td>\n",
       "      <td>4823191</td>\n",
       "      <td>3374368</td>\n",
       "      <td>682204</td>\n",
       "      <td>50537</td>\n",
       "      <td>2641627</td>\n",
       "      <td>1433017</td>\n",
       "      <td>579597</td>\n",
       "      <td>42710</td>\n",
       "      <td>810710</td>\n",
       "      <td>15806</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>安徽</td>\n",
       "      <td>4430924</td>\n",
       "      <td>2934620</td>\n",
       "      <td>763320</td>\n",
       "      <td>57568</td>\n",
       "      <td>2113732</td>\n",
       "      <td>1474844</td>\n",
       "      <td>758688</td>\n",
       "      <td>67046</td>\n",
       "      <td>649110</td>\n",
       "      <td>21460</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>河北</td>\n",
       "      <td>4348298</td>\n",
       "      <td>2873074</td>\n",
       "      <td>718031</td>\n",
       "      <td>12885</td>\n",
       "      <td>2142158</td>\n",
       "      <td>1457822</td>\n",
       "      <td>777408</td>\n",
       "      <td>14536</td>\n",
       "      <td>665878</td>\n",
       "      <td>17402</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>浙江</td>\n",
       "      <td>3829609</td>\n",
       "      <td>2657453</td>\n",
       "      <td>958511</td>\n",
       "      <td>21104</td>\n",
       "      <td>1677838</td>\n",
       "      <td>1161901</td>\n",
       "      <td>741256</td>\n",
       "      <td>18656</td>\n",
       "      <td>401989</td>\n",
       "      <td>10255</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>湖北</td>\n",
       "      <td>3791526</td>\n",
       "      <td>2575364</td>\n",
       "      <td>513293</td>\n",
       "      <td>38280</td>\n",
       "      <td>2023791</td>\n",
       "      <td>1201776</td>\n",
       "      <td>502683</td>\n",
       "      <td>35276</td>\n",
       "      <td>663817</td>\n",
       "      <td>14386</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>广西</td>\n",
       "      <td>3249324</td>\n",
       "      <td>2289631</td>\n",
       "      <td>489310</td>\n",
       "      <td>65238</td>\n",
       "      <td>1735083</td>\n",
       "      <td>947443</td>\n",
       "      <td>351742</td>\n",
       "      <td>46515</td>\n",
       "      <td>549186</td>\n",
       "      <td>12250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>辽宁</td>\n",
       "      <td>3224900</td>\n",
       "      <td>1992382</td>\n",
       "      <td>549823</td>\n",
       "      <td>6985</td>\n",
       "      <td>1435574</td>\n",
       "      <td>1222706</td>\n",
       "      <td>691625</td>\n",
       "      <td>10409</td>\n",
       "      <td>520672</td>\n",
       "      <td>9812</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>云南</td>\n",
       "      <td>2700426</td>\n",
       "      <td>1935997</td>\n",
       "      <td>249404</td>\n",
       "      <td>15792</td>\n",
       "      <td>1670801</td>\n",
       "      <td>755923</td>\n",
       "      <td>234866</td>\n",
       "      <td>12714</td>\n",
       "      <td>508343</td>\n",
       "      <td>8506</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>江西</td>\n",
       "      <td>2564797</td>\n",
       "      <td>1827551</td>\n",
       "      <td>288918</td>\n",
       "      <td>38916</td>\n",
       "      <td>1499717</td>\n",
       "      <td>729149</td>\n",
       "      <td>259688</td>\n",
       "      <td>31140</td>\n",
       "      <td>438321</td>\n",
       "      <td>8097</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>重庆</td>\n",
       "      <td>2556992</td>\n",
       "      <td>1791342</td>\n",
       "      <td>517457</td>\n",
       "      <td>56279</td>\n",
       "      <td>1217606</td>\n",
       "      <td>757404</td>\n",
       "      <td>357111</td>\n",
       "      <td>45159</td>\n",
       "      <td>355134</td>\n",
       "      <td>8246</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>陕西</td>\n",
       "      <td>2360804</td>\n",
       "      <td>1614811</td>\n",
       "      <td>299799</td>\n",
       "      <td>15676</td>\n",
       "      <td>1299336</td>\n",
       "      <td>739192</td>\n",
       "      <td>299329</td>\n",
       "      <td>16285</td>\n",
       "      <td>423578</td>\n",
       "      <td>6801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>黑龙江</td>\n",
       "      <td>2305384</td>\n",
       "      <td>1486670</td>\n",
       "      <td>380125</td>\n",
       "      <td>7422</td>\n",
       "      <td>1099123</td>\n",
       "      <td>811399</td>\n",
       "      <td>446736</td>\n",
       "      <td>9004</td>\n",
       "      <td>355659</td>\n",
       "      <td>7315</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>贵州</td>\n",
       "      <td>2292084</td>\n",
       "      <td>1588428</td>\n",
       "      <td>347928</td>\n",
       "      <td>63175</td>\n",
       "      <td>1177325</td>\n",
       "      <td>698692</td>\n",
       "      <td>302096</td>\n",
       "      <td>50327</td>\n",
       "      <td>346269</td>\n",
       "      <td>4964</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>福建</td>\n",
       "      <td>2263365</td>\n",
       "      <td>1652877</td>\n",
       "      <td>386611</td>\n",
       "      <td>25055</td>\n",
       "      <td>1241211</td>\n",
       "      <td>603766</td>\n",
       "      <td>266061</td>\n",
       "      <td>16760</td>\n",
       "      <td>320945</td>\n",
       "      <td>6722</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>山西</td>\n",
       "      <td>2011676</td>\n",
       "      <td>1356930</td>\n",
       "      <td>358537</td>\n",
       "      <td>9188</td>\n",
       "      <td>989205</td>\n",
       "      <td>649271</td>\n",
       "      <td>349085</td>\n",
       "      <td>9396</td>\n",
       "      <td>290790</td>\n",
       "      <td>5475</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>吉林</td>\n",
       "      <td>1678527</td>\n",
       "      <td>1088121</td>\n",
       "      <td>240937</td>\n",
       "      <td>4193</td>\n",
       "      <td>842991</td>\n",
       "      <td>585107</td>\n",
       "      <td>291051</td>\n",
       "      <td>5462</td>\n",
       "      <td>288594</td>\n",
       "      <td>5299</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>上海</td>\n",
       "      <td>1619298</td>\n",
       "      <td>976043</td>\n",
       "      <td>294382</td>\n",
       "      <td>3637</td>\n",
       "      <td>678024</td>\n",
       "      <td>634555</td>\n",
       "      <td>361593</td>\n",
       "      <td>7334</td>\n",
       "      <td>265628</td>\n",
       "      <td>8700</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>甘肃</td>\n",
       "      <td>1578166</td>\n",
       "      <td>1080706</td>\n",
       "      <td>145232</td>\n",
       "      <td>11611</td>\n",
       "      <td>923863</td>\n",
       "      <td>492780</td>\n",
       "      <td>147822</td>\n",
       "      <td>13806</td>\n",
       "      <td>331152</td>\n",
       "      <td>4680</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>内蒙古</td>\n",
       "      <td>1377709</td>\n",
       "      <td>910556</td>\n",
       "      <td>255624</td>\n",
       "      <td>5500</td>\n",
       "      <td>649432</td>\n",
       "      <td>464032</td>\n",
       "      <td>300800</td>\n",
       "      <td>5886</td>\n",
       "      <td>157346</td>\n",
       "      <td>3121</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>北京</td>\n",
       "      <td>1207750</td>\n",
       "      <td>730261</td>\n",
       "      <td>192967</td>\n",
       "      <td>3260</td>\n",
       "      <td>534034</td>\n",
       "      <td>473480</td>\n",
       "      <td>227085</td>\n",
       "      <td>5728</td>\n",
       "      <td>240667</td>\n",
       "      <td>4009</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>新疆</td>\n",
       "      <td>1086542</td>\n",
       "      <td>776621</td>\n",
       "      <td>209665</td>\n",
       "      <td>7834</td>\n",
       "      <td>559122</td>\n",
       "      <td>307958</td>\n",
       "      <td>163461</td>\n",
       "      <td>7559</td>\n",
       "      <td>136938</td>\n",
       "      <td>1963</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>天津</td>\n",
       "      <td>781761</td>\n",
       "      <td>483217</td>\n",
       "      <td>141505</td>\n",
       "      <td>1702</td>\n",
       "      <td>340010</td>\n",
       "      <td>296023</td>\n",
       "      <td>169992</td>\n",
       "      <td>3266</td>\n",
       "      <td>122765</td>\n",
       "      <td>2521</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>海南</td>\n",
       "      <td>524487</td>\n",
       "      <td>359523</td>\n",
       "      <td>93679</td>\n",
       "      <td>3059</td>\n",
       "      <td>262785</td>\n",
       "      <td>162699</td>\n",
       "      <td>57477</td>\n",
       "      <td>3390</td>\n",
       "      <td>101832</td>\n",
       "      <td>2265</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>宁夏</td>\n",
       "      <td>295500</td>\n",
       "      <td>192913</td>\n",
       "      <td>39734</td>\n",
       "      <td>2191</td>\n",
       "      <td>150988</td>\n",
       "      <td>102048</td>\n",
       "      <td>53330</td>\n",
       "      <td>2809</td>\n",
       "      <td>45909</td>\n",
       "      <td>539</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>青海</td>\n",
       "      <td>273812</td>\n",
       "      <td>196778</td>\n",
       "      <td>26127</td>\n",
       "      <td>2328</td>\n",
       "      <td>168323</td>\n",
       "      <td>76458</td>\n",
       "      <td>23946</td>\n",
       "      <td>2692</td>\n",
       "      <td>49820</td>\n",
       "      <td>576</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>西藏</td>\n",
       "      <td>123015</td>\n",
       "      <td>97930</td>\n",
       "      <td>7501</td>\n",
       "      <td>653</td>\n",
       "      <td>89776</td>\n",
       "      <td>23247</td>\n",
       "      <td>1469</td>\n",
       "      <td>200</td>\n",
       "      <td>21578</td>\n",
       "      <td>1838</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     地区       合计       小计    单身老人户  一个老年人与未成年的亲属户       其他     小计.1  \\\n",
       "0    山东  6746757  4284534  1490848          23741  2769945  2432541   \n",
       "1    四川  6710282  4772272  1106491         113482  3552299  1912887   \n",
       "2    江苏  6147499  3888399  1062588          35712  2790099  2223808   \n",
       "3    河南  5754338  3782040   826922          77762  2877356  1939986   \n",
       "4    广东  5377567  3893992   802212          84397  3007383  1461232   \n",
       "5    湖南  4823191  3374368   682204          50537  2641627  1433017   \n",
       "6    安徽  4430924  2934620   763320          57568  2113732  1474844   \n",
       "7    河北  4348298  2873074   718031          12885  2142158  1457822   \n",
       "8    浙江  3829609  2657453   958511          21104  1677838  1161901   \n",
       "9    湖北  3791526  2575364   513293          38280  2023791  1201776   \n",
       "10   广西  3249324  2289631   489310          65238  1735083   947443   \n",
       "11   辽宁  3224900  1992382   549823           6985  1435574  1222706   \n",
       "12   云南  2700426  1935997   249404          15792  1670801   755923   \n",
       "13   江西  2564797  1827551   288918          38916  1499717   729149   \n",
       "14   重庆  2556992  1791342   517457          56279  1217606   757404   \n",
       "15   陕西  2360804  1614811   299799          15676  1299336   739192   \n",
       "16  黑龙江  2305384  1486670   380125           7422  1099123   811399   \n",
       "17   贵州  2292084  1588428   347928          63175  1177325   698692   \n",
       "18   福建  2263365  1652877   386611          25055  1241211   603766   \n",
       "19   山西  2011676  1356930   358537           9188   989205   649271   \n",
       "20   吉林  1678527  1088121   240937           4193   842991   585107   \n",
       "21   上海  1619298   976043   294382           3637   678024   634555   \n",
       "22   甘肃  1578166  1080706   145232          11611   923863   492780   \n",
       "23  内蒙古  1377709   910556   255624           5500   649432   464032   \n",
       "24   北京  1207750   730261   192967           3260   534034   473480   \n",
       "25   新疆  1086542   776621   209665           7834   559122   307958   \n",
       "26   天津   781761   483217   141505           1702   340010   296023   \n",
       "27   海南   524487   359523    93679           3059   262785   162699   \n",
       "28   宁夏   295500   192913    39734           2191   150988   102048   \n",
       "29   青海   273812   196778    26127           2328   168323    76458   \n",
       "30   西藏   123015    97930     7501            653    89776    23247   \n",
       "\n",
       "    只有一对老夫妇的户  一对老夫妇与未成年的亲属户     其他.1  有三个65岁及以上老年人的户  \n",
       "0     1572344          27870   832327           29682  \n",
       "1      804349          84095  1024443           25123  \n",
       "2     1129456          41957  1052395           35292  \n",
       "3      860915          78609  1000462           32312  \n",
       "4      447449          59839   953944           22343  \n",
       "5      579597          42710   810710           15806  \n",
       "6      758688          67046   649110           21460  \n",
       "7      777408          14536   665878           17402  \n",
       "8      741256          18656   401989           10255  \n",
       "9      502683          35276   663817           14386  \n",
       "10     351742          46515   549186           12250  \n",
       "11     691625          10409   520672            9812  \n",
       "12     234866          12714   508343            8506  \n",
       "13     259688          31140   438321            8097  \n",
       "14     357111          45159   355134            8246  \n",
       "15     299329          16285   423578            6801  \n",
       "16     446736           9004   355659            7315  \n",
       "17     302096          50327   346269            4964  \n",
       "18     266061          16760   320945            6722  \n",
       "19     349085           9396   290790            5475  \n",
       "20     291051           5462   288594            5299  \n",
       "21     361593           7334   265628            8700  \n",
       "22     147822          13806   331152            4680  \n",
       "23     300800           5886   157346            3121  \n",
       "24     227085           5728   240667            4009  \n",
       "25     163461           7559   136938            1963  \n",
       "26     169992           3266   122765            2521  \n",
       "27      57477           3390   101832            2265  \n",
       "28      53330           2809    45909             539  \n",
       "29      23946           2692    49820             576  \n",
       "30       1469            200    21578            1838  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "renkou = pd.read_csv('data/老年人口分布.csv',encoding=\"gbk\")\n",
    "renkou"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7549bb00",
   "metadata": {},
   "source": [
    "### 地图（√）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a3273b64",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'china':'https://assets.pyecharts.org/assets/maps/china'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"8bfdc133e6f74290a05bdceb0079de3f\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'china'], function(echarts) {\n",
       "                var chart_8bfdc133e6f74290a05bdceb0079de3f = echarts.init(\n",
       "                    document.getElementById('8bfdc133e6f74290a05bdceb0079de3f'), 'white', {renderer: 'canvas'});\n",
       "                var option_8bfdc133e6f74290a05bdceb0079de3f = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"map\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"mapType\": \"china\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u4e1c\",\n",
       "                    \"value\": 6746757\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u56db\\u5ddd\",\n",
       "                    \"value\": 6710282\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u82cf\",\n",
       "                    \"value\": 6147499\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5357\",\n",
       "                    \"value\": 5754338\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u4e1c\",\n",
       "                    \"value\": 5377567\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5357\",\n",
       "                    \"value\": 4823191\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b89\\u5fbd\",\n",
       "                    \"value\": 4430924\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5317\",\n",
       "                    \"value\": 4348298\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d59\\u6c5f\",\n",
       "                    \"value\": 3829609\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5317\",\n",
       "                    \"value\": 3791526\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u897f\",\n",
       "                    \"value\": 3249324\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8fbd\\u5b81\",\n",
       "                    \"value\": 3224900\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e91\\u5357\",\n",
       "                    \"value\": 2700426\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u897f\",\n",
       "                    \"value\": 2564797\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u91cd\\u5e86\",\n",
       "                    \"value\": 2556992\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9655\\u897f\",\n",
       "                    \"value\": 2360804\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9ed1\\u9f99\\u6c5f\",\n",
       "                    \"value\": 2305384\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8d35\\u5dde\",\n",
       "                    \"value\": 2292084\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u798f\\u5efa\",\n",
       "                    \"value\": 2263365\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u897f\",\n",
       "                    \"value\": 2011676\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5409\\u6797\",\n",
       "                    \"value\": 1678527\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e0a\\u6d77\",\n",
       "                    \"value\": 1619298\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7518\\u8083\",\n",
       "                    \"value\": 1578166\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5185\\u8499\\u53e4\",\n",
       "                    \"value\": 1377709\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5317\\u4eac\",\n",
       "                    \"value\": 1207750\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65b0\\u7586\",\n",
       "                    \"value\": 1086542\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5929\\u6d25\",\n",
       "                    \"value\": 781761\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d77\\u5357\",\n",
       "                    \"value\": 524487\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b81\\u590f\",\n",
       "                    \"value\": 295500\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9752\\u6d77\",\n",
       "                    \"value\": 273812\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u897f\\u85cf\",\n",
       "                    \"value\": 123015\n",
       "                }\n",
       "            ],\n",
       "            \"roam\": true,\n",
       "            \"aspectScale\": 0.75,\n",
       "            \"nameProperty\": \"name\",\n",
       "            \"selectedMode\": false,\n",
       "            \"zoom\": 1,\n",
       "            \"mapValueCalculation\": \"sum\",\n",
       "            \"showLegendSymbol\": false,\n",
       "            \"emphasis\": {},\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5168\\u56fd\\u8001\\u5e74\\u4eba\\u53e3\\u5206\\u5e03\\u5730\\u56fe\",\n",
       "            \"subtext\": \"\\u8fd9\\u662f\\u6211\\u56fd\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\\u7684\\u5206\\u5e03\\u5730\\u56fe \\n\\n\\u4ece\\u4e2d\\u6211\\u4eec\\u53ef\\u4ee5\\u770b\\u5230\\u5c71\\u4e1c\\u7701\\u5730\\u533a\\u7684\\u989c\\u8272\\u6700\\u6df1\\uff0c\\u4e5f\\u5c31\\u662f\\u5c71\\u4e1c\\u7701\\u7684\\u8001\\u5e74\\u4eba\\u53e3\\u6570\\u91cf\\u6700\\u591a\\n\\n\\u897f\\u85cf\\u7701\\u5730\\u533a\\u7684\\u989c\\u8272\\u6700\\u6d45\\uff0c\\u4e5f\\u5c31\\u662f\\u897f\\u85cf\\u7684\\u8001\\u5e74\\u4eba\\u53e3\\u6570\\u91cf\\u6700\\u5c11\\uff0c\\u53ef\\u80fd\\u8ddf\\u5f53\\u5730\\u7684\\u5730\\u7406\\u73af\\u5883\\u76f8\\u5173\",\n",
       "            \"top\": \"0\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"continuous\",\n",
       "        \"min\": 123015,\n",
       "        \"max\": 6746757,\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"#C2E7C0\",\n",
       "                \"#61BDCD\",\n",
       "                \"#0D6DAE\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 140,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "                chart_8bfdc133e6f74290a05bdceb0079de3f.setOption(option_8bfdc133e6f74290a05bdceb0079de3f);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1baec53ed60>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x_data = renkou['地区'].tolist()\n",
    "y_data =renkou['合计'].tolist()\n",
    "\n",
    "m = Map()\n",
    "m.add('',[list(z) for z in zip(x_data,y_data)],maptype = 'china',is_map_symbol_show=False)\n",
    "m.set_series_opts(label_opts = opts.LabelOpts(is_show=True))\n",
    "m.set_global_opts(title_opts = opts.TitleOpts(title = '全国老年人口分布地图',\n",
    "                                              subtitle=\"这是我国不同省份的老年人口的分布地图 \\n\\n从中我们可以看到山东省地区的颜色最深，也就是山东省的老年人口数量最多\\n\\n西藏省地区的颜色最浅，也就是西藏的老年人口数量最少，可能跟当地的地理环境相关\",\n",
    "                                                pos_top=\"0\", ),\n",
    "visualmap_opts = opts.VisualMapOpts(min_=renkou['合计'].min(),max_=renkou['合计'].max(),\n",
    "range_color=['#C2E7C0','#61BDCD','#0D6DAE']))\n",
    "m.render_notebook()\n",
    "# m.render('html/全国老年人口分布地图.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8b36d1ba",
   "metadata": {},
   "source": [
    "### 柱状图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "224e22ca",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"bb148bae6822493192c93117371a675b\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_bb148bae6822493192c93117371a675b = echarts.init(\n",
       "                    document.getElementById('bb148bae6822493192c93117371a675b'), 'white', {renderer: 'canvas'});\n",
       "                var option_bb148bae6822493192c93117371a675b = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u8001\\u5e74\\u4eba\\u53e3\\u5730\\u533a\\u5206\\u5e03\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                6746757,\n",
       "                6710282,\n",
       "                6147499,\n",
       "                5754338,\n",
       "                5377567,\n",
       "                4823191,\n",
       "                4430924,\n",
       "                4348298,\n",
       "                3829609,\n",
       "                3791526,\n",
       "                3249324,\n",
       "                3224900,\n",
       "                2700426,\n",
       "                2564797,\n",
       "                2556992,\n",
       "                2360804,\n",
       "                2305384,\n",
       "                2292084,\n",
       "                2263365,\n",
       "                2011676,\n",
       "                1678527,\n",
       "                1619298,\n",
       "                1578166,\n",
       "                1377709,\n",
       "                1207750,\n",
       "                1086542,\n",
       "                781761,\n",
       "                524487,\n",
       "                295500,\n",
       "                273812,\n",
       "                123015\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8001\\u5e74\\u4eba\\u53e3\\u5730\\u533a\\u5206\\u5e03\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u8001\\u5e74\\u4eba\\u53e3\\u5730\\u533a\\u5206\\u5e03\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u5c71\\u4e1c\",\n",
       "                \"\\u56db\\u5ddd\",\n",
       "                \"\\u6c5f\\u82cf\",\n",
       "                \"\\u6cb3\\u5357\",\n",
       "                \"\\u5e7f\\u4e1c\",\n",
       "                \"\\u6e56\\u5357\",\n",
       "                \"\\u5b89\\u5fbd\",\n",
       "                \"\\u6cb3\\u5317\",\n",
       "                \"\\u6d59\\u6c5f\",\n",
       "                \"\\u6e56\\u5317\",\n",
       "                \"\\u5e7f\\u897f\",\n",
       "                \"\\u8fbd\\u5b81\",\n",
       "                \"\\u4e91\\u5357\",\n",
       "                \"\\u6c5f\\u897f\",\n",
       "                \"\\u91cd\\u5e86\",\n",
       "                \"\\u9655\\u897f\",\n",
       "                \"\\u9ed1\\u9f99\\u6c5f\",\n",
       "                \"\\u8d35\\u5dde\",\n",
       "                \"\\u798f\\u5efa\",\n",
       "                \"\\u5c71\\u897f\",\n",
       "                \"\\u5409\\u6797\",\n",
       "                \"\\u4e0a\\u6d77\",\n",
       "                \"\\u7518\\u8083\",\n",
       "                \"\\u5185\\u8499\\u53e4\",\n",
       "                \"\\u5317\\u4eac\",\n",
       "                \"\\u65b0\\u7586\",\n",
       "                \"\\u5929\\u6d25\",\n",
       "                \"\\u6d77\\u5357\",\n",
       "                \"\\u5b81\\u590f\",\n",
       "                \"\\u9752\\u6d77\",\n",
       "                \"\\u897f\\u85cf\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u8001\\u5e74\\u4eba\\u53e3\\u5730\\u533a\\u5206\\u5e03\",\n",
       "            \"subtext\": \"\\u8fd9\\u662f\\u6211\\u56fd\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\\u7684\\u5206\\u5e03\\u5730\\u56fe\\uff0c\\u4ece\\u4e2d\\u6211\\u4eec\\u53ef\\u4ee5\\u770b\\u5230\\u5c71\\u4e1c\\u7701\\u5730\\u533a\\u7684\\u989c\\u8272\\u6700\\u6df1\\uff0c\\u4e5f\\u5c31\\u662f\\u5c71\\u4e1c\\u7701\\u7684\\u8001\\u5e74\\u4eba\\u53e3\\u6570\\u91cf\\u6700\\u591a\",\n",
       "            \"top\": \"0\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false,\n",
       "        \"filterMode\": \"filter\"\n",
       "    }\n",
       "};\n",
       "                chart_bb148bae6822493192c93117371a675b.setOption(option_bb148bae6822493192c93117371a675b);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1baec577550>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts.charts import Bar\n",
    "#xy轴数据\n",
    "x= renkou['地区']\n",
    "x1=list(x)\n",
    "\n",
    "y=renkou['合计']\n",
    "y1=list(y)\n",
    "\n",
    "#柱形图\n",
    "l1=x1\n",
    "l2=y1\n",
    "bar = (\n",
    "    Bar()\n",
    "    .add_xaxis(l1)\n",
    "    .add_yaxis(\"老年人口地区分布\", l2)\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"老年人口地区分布\",\n",
    "                                                subtitle=\"这是我国不同省份的老年人口的分布地图，从中我们可以看到山东省地区的颜色最深，也就是山东省的老年人口数量最多\",\n",
    "                                                pos_top=\"0\", ),\n",
    "                     datazoom_opts=opts.DataZoomOpts(type_=\"slider\"))\n",
    ")\n",
    "bar.render_notebook()\n",
    "# bar.render('不同行业公司数量图.html')\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2182d27e",
   "metadata": {},
   "source": [
    "### 条形图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "58714eb9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"e50d63282dd74ec59fb8d1c3ef7b8465\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_e50d63282dd74ec59fb8d1c3ef7b8465 = echarts.init(\n",
       "                    document.getElementById('e50d63282dd74ec59fb8d1c3ef7b8465'), 'white', {renderer: 'canvas'});\n",
       "                var option_e50d63282dd74ec59fb8d1c3ef7b8465 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                123015,\n",
       "                273812,\n",
       "                295500,\n",
       "                524487,\n",
       "                781761,\n",
       "                1086542,\n",
       "                1207750,\n",
       "                1377709,\n",
       "                1578166,\n",
       "                1619298,\n",
       "                1678527,\n",
       "                2011676,\n",
       "                2263365,\n",
       "                2292084,\n",
       "                2305384,\n",
       "                2360804,\n",
       "                2556992,\n",
       "                2564797,\n",
       "                2700426,\n",
       "                3224900,\n",
       "                3249324,\n",
       "                3791526,\n",
       "                3829609,\n",
       "                4348298,\n",
       "                4430924,\n",
       "                4823191,\n",
       "                5377567,\n",
       "                5754338,\n",
       "                6147499,\n",
       "                6710282,\n",
       "                6746757\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"symbolSize\": 80,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"average\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"max\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"min\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u897f\\u85cf\",\n",
       "                \"\\u9752\\u6d77\",\n",
       "                \"\\u5b81\\u590f\",\n",
       "                \"\\u6d77\\u5357\",\n",
       "                \"\\u5929\\u6d25\",\n",
       "                \"\\u65b0\\u7586\",\n",
       "                \"\\u5317\\u4eac\",\n",
       "                \"\\u5185\\u8499\\u53e4\",\n",
       "                \"\\u7518\\u8083\",\n",
       "                \"\\u4e0a\\u6d77\",\n",
       "                \"\\u5409\\u6797\",\n",
       "                \"\\u5c71\\u897f\",\n",
       "                \"\\u798f\\u5efa\",\n",
       "                \"\\u8d35\\u5dde\",\n",
       "                \"\\u9ed1\\u9f99\\u6c5f\",\n",
       "                \"\\u9655\\u897f\",\n",
       "                \"\\u91cd\\u5e86\",\n",
       "                \"\\u6c5f\\u897f\",\n",
       "                \"\\u4e91\\u5357\",\n",
       "                \"\\u8fbd\\u5b81\",\n",
       "                \"\\u5e7f\\u897f\",\n",
       "                \"\\u6e56\\u5317\",\n",
       "                \"\\u6d59\\u6c5f\",\n",
       "                \"\\u6cb3\\u5317\",\n",
       "                \"\\u5b89\\u5fbd\",\n",
       "                \"\\u6e56\\u5357\",\n",
       "                \"\\u5e7f\\u4e1c\",\n",
       "                \"\\u6cb3\\u5357\",\n",
       "                \"\\u6c5f\\u82cf\",\n",
       "                \"\\u56db\\u5ddd\",\n",
       "                \"\\u5c71\\u4e1c\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e2d\\u56fd\\u4eba\\u53e3\\u8001\\u9f84\\u5316\\u5730\\u533a\\u5206\\u5e03\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_e50d63282dd74ec59fb8d1c3ef7b8465.setOption(option_e50d63282dd74ec59fb8d1c3ef7b8465);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1bae9f31af0>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 条形图\n",
    "import random\n",
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Bar\n",
    "\n",
    "x=renkou['地区']\n",
    "x1=list(x)\n",
    "x1.reverse()\n",
    "x1\n",
    "\n",
    "y=renkou['合计']\n",
    "y1=list(y)\n",
    "y1.reverse()\n",
    "y1\n",
    "\n",
    "x_vals1 = x1\n",
    "y_vals = y1\n",
    "bar = Bar().add_xaxis(x_vals1)      \n",
    "bar.add_yaxis('不同省份的老年人口', y_vals, \n",
    "               markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_='average'),\n",
    "                                                 opts.MarkPointItem(type_='max'),\n",
    "                                                 opts.MarkPointItem(type_='min')], \n",
    "                                                symbol_size=80)\n",
    "              ) \n",
    "bar.set_series_opts(label_opts=opts.LabelOpts(is_show=True, position='right'))\n",
    "bar.set_global_opts(title_opts=opts.TitleOpts(title='中国人口老龄化地区分布'))\n",
    "bar.reversal_axis() #翻转XY轴，将柱状图转换为条形图\n",
    "bar.render_notebook()\n",
    "# bar.render('条形图.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a7dbb7c0",
   "metadata": {},
   "source": [
    "## 老年人口不同类型分布"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "9e4b65e2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>老龄人口</th>\n",
       "      <th>占比(%)</th>\n",
       "      <th>Unnamed: 2</th>\n",
       "      <th>Unnamed: 3</th>\n",
       "      <th>Unnamed: 4</th>\n",
       "      <th>Unnamed: 5</th>\n",
       "      <th>Unnamed: 6</th>\n",
       "      <th>Unnamed: 7</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>空巢老人</td>\n",
       "      <td>49</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>失能老人</td>\n",
       "      <td>17</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>高龄老人</td>\n",
       "      <td>12</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>其他</td>\n",
       "      <td>22</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   老龄人口  占比(%)  Unnamed: 2  Unnamed: 3  Unnamed: 4  Unnamed: 5  Unnamed: 6  \\\n",
       "0  空巢老人     49         NaN         NaN         NaN         NaN         NaN   \n",
       "1  失能老人     17         NaN         NaN         NaN         NaN         NaN   \n",
       "2  高龄老人     12         NaN         NaN         NaN         NaN         NaN   \n",
       "3    其他     22         NaN         NaN         NaN         NaN         NaN   \n",
       "\n",
       "   Unnamed: 7  \n",
       "0         NaN  \n",
       "1         NaN  \n",
       "2         NaN  \n",
       "3         NaN  "
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bizhong = pd.read_csv('data/中国老龄人口比重分布.csv',encoding=\"gbk\")\n",
    "bizhong "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "76d7b7e9",
   "metadata": {},
   "source": [
    "### 饼图(√）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "42a77be3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"e082ea731130451082ca37f2eedc91f9\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_e082ea731130451082ca37f2eedc91f9 = echarts.init(\n",
       "                    document.getElementById('e082ea731130451082ca37f2eedc91f9'), 'white', {renderer: 'canvas'});\n",
       "                var option_e082ea731130451082ca37f2eedc91f9 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u7a7a\\u5de2\\u8001\\u4eba\",\n",
       "                    \"value\": 49\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5931\\u80fd\\u8001\\u4eba\",\n",
       "                    \"value\": 17\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9ad8\\u9f84\\u8001\\u4eba\",\n",
       "                    \"value\": 12\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5176\\u4ed6\",\n",
       "                    \"value\": 22\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"0%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{b}: {c}\"\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u7a7a\\u5de2\\u8001\\u4eba\",\n",
       "                \"\\u5931\\u80fd\\u8001\\u4eba\",\n",
       "                \"\\u9ad8\\u9f84\\u8001\\u4eba\",\n",
       "                \"\\u5176\\u4ed6\"\n",
       "            ],\n",
       "            \"selected\": {}\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    }\n",
       "};\n",
       "                chart_e082ea731130451082ca37f2eedc91f9.setOption(option_e082ea731130451082ca37f2eedc91f9);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1baec5777c0>"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x=bizhong[\"老龄人口\"]\n",
    "x_data=list(x)\n",
    "y=bizhong[\"占比(%)\"]\n",
    "y_data=list(y)\n",
    "c = (\n",
    "    Pie()\n",
    "    .add(\"\", [list(z) for z in zip(x_data, y_data)])   # zip函数两个部分组合在一起list(zip(x,y))-----> [(x,y)]\n",
    "#     .set_global_opts(title_opts=opts.TitleOpts(title=\"三大湾区总估值\"))  # 标题\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(formatter=\"{b}: {c}\"))  # 数据标签设置\n",
    ")\n",
    "\n",
    "c.render_notebook()\n",
    "# c.render('html/老龄人口比重.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 157,
   "id": "ec28ca61",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"be7b1c7fd8f84e0fb805e592c35f53e5\" style=\"width:1600px; height:800px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_be7b1c7fd8f84e0fb805e592c35f53e5 = echarts.init(\n",
       "                    document.getElementById('be7b1c7fd8f84e0fb805e592c35f53e5'), 'white', {renderer: 'canvas'});\n",
       "                var option_be7b1c7fd8f84e0fb805e592c35f53e5 = {\n",
       "    \"backgroundColor\": \"#2c343c\",\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"name\": \"\\u8bbf\\u95ee\\u6765\\u6e90\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u9ad8\\u9f84\\u8001\\u4eba\",\n",
       "                    \"value\": 12\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5931\\u80fd\\u8001\\u4eba\",\n",
       "                    \"value\": 17\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5176\\u4ed6\",\n",
       "                    \"value\": 22\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7a7a\\u5de2\\u8001\\u4eba\",\n",
       "                    \"value\": 49\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": \"55%\",\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"roseType\": \"radius\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"color\": \"rgba(255, 255, 255, 0.3)\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"formatter\": \"{a} <br/>{b}: {c} ({d}%)\",\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u9ad8\\u9f84\\u8001\\u4eba\",\n",
       "                \"\\u5931\\u80fd\\u8001\\u4eba\",\n",
       "                \"\\u5176\\u4ed6\",\n",
       "                \"\\u7a7a\\u5de2\\u8001\\u4eba\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": false,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Customized Pie\",\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"20\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textStyle\": {\n",
       "                \"color\": \"#fff\"\n",
       "            }\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_be7b1c7fd8f84e0fb805e592c35f53e5.setOption(option_be7b1c7fd8f84e0fb805e592c35f53e5);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be60c5bb0>"
      ]
     },
     "execution_count": 157,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Pie\n",
    "#xy轴数据\n",
    "x_data=bizhong[\"老龄人口\"]\n",
    "x_data=list(x_data)\n",
    "\n",
    "y_data=bizhong[\"占比(%)\"]\n",
    "y_data=list(y_data)\n",
    "\n",
    "# x_data = [\"直接访问\", \"邮件营销\", \"联盟广告\", \"视频广告\", \"搜索引擎\"]\n",
    "# y_data = [335, 310, 274, 235, 400]\n",
    "data_pair = [list(z) for z in zip(x_data, y_data)]\n",
    "data_pair.sort(key=lambda x: x[1])\n",
    "\n",
    "(\n",
    "    Pie(init_opts=opts.InitOpts(width=\"1600px\", height=\"800px\", bg_color=\"#2c343c\"))\n",
    "    .add(\n",
    "        series_name=\"访问来源\",\n",
    "        data_pair=data_pair,\n",
    "        rosetype=\"radius\",\n",
    "        radius=\"55%\",\n",
    "        center=[\"50%\", \"50%\"],\n",
    "        label_opts=opts.LabelOpts(is_show=False, position=\"center\"),\n",
    "    )\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(\n",
    "            title=\"Customized Pie\",\n",
    "            pos_left=\"center\",\n",
    "            pos_top=\"20\",\n",
    "            title_textstyle_opts=opts.TextStyleOpts(color=\"#fff\"),\n",
    "        ),\n",
    "        legend_opts=opts.LegendOpts(is_show=False),\n",
    "    )\n",
    "    .set_series_opts(\n",
    "        tooltip_opts=opts.TooltipOpts(\n",
    "            trigger=\"item\", formatter=\"{a} <br/>{b}: {c} ({d}%)\"\n",
    "        ),\n",
    "        label_opts=opts.LabelOpts(color=\"rgba(255, 255, 255, 0.3)\"),\n",
    "    )\n",
    "#     .render(\"customized_pie.html\")\n",
    "    .render_notebook()\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7cb27050",
   "metadata": {},
   "source": [
    "## 老年人口不同喜欢的养老方式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 160,
   "id": "51cce9f7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>喜欢的养老方式</th>\n",
       "      <th>东部</th>\n",
       "      <th>中部</th>\n",
       "      <th>西部</th>\n",
       "      <th>东北部</th>\n",
       "      <th>合计</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>与子女一起居住</td>\n",
       "      <td>39.7</td>\n",
       "      <td>39.4</td>\n",
       "      <td>52.1</td>\n",
       "      <td>33.6</td>\n",
       "      <td>42.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>独居（或与配偶住），子女最好住在附近</td>\n",
       "      <td>41.0</td>\n",
       "      <td>42.3</td>\n",
       "      <td>32.2</td>\n",
       "      <td>41.8</td>\n",
       "      <td>39.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>独居（或与配偶住），子女在不在附近</td>\n",
       "      <td>17.2</td>\n",
       "      <td>15.6</td>\n",
       "      <td>13.9</td>\n",
       "      <td>21.8</td>\n",
       "      <td>16.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>敬老院、福利院</td>\n",
       "      <td>1.2</td>\n",
       "      <td>1.9</td>\n",
       "      <td>0.8</td>\n",
       "      <td>2.0</td>\n",
       "      <td>1.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>其他</td>\n",
       "      <td>0.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>0.8</td>\n",
       "      <td>0.7</td>\n",
       "      <td>0.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>村里的日托所</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0.1</td>\n",
       "      <td>0.3</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>商业性老年公寓</td>\n",
       "      <td>0.2</td>\n",
       "      <td>0.1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              喜欢的养老方式    东部    中部    西部   东北部    合计\n",
       "0             与子女一起居住  39.7  39.4  52.1  33.6  42.3\n",
       "1  独居（或与配偶住），子女最好住在附近  41.0  42.3  32.2  41.8  39.3\n",
       "2   独居（或与配偶住），子女在不在附近  17.2  15.6  13.9  21.8  16.3\n",
       "3             敬老院、福利院   1.2   1.9   0.8   2.0   1.3\n",
       "4                  其他   0.4   0.5   0.8   0.7   0.6\n",
       "5              村里的日托所   0.2   0.1   0.3   0.0   0.2\n",
       "6             商业性老年公寓   0.2   0.1   0.0   0.0   0.1"
      ]
     },
     "execution_count": 160,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "fangshi= pd.read_csv('data/养老方式.csv',encoding=\"gbk\")\n",
    "fangshi"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "14730417",
   "metadata": {},
   "source": [
    "### 条形图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "id": "26e3e595",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"959d83cc220843dc84315bdacfc72b02\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_959d83cc220843dc84315bdacfc72b02 = echarts.init(\n",
       "                    document.getElementById('959d83cc220843dc84315bdacfc72b02'), 'white', {renderer: 'canvas'});\n",
       "                var option_959d83cc220843dc84315bdacfc72b02 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e0d\\u540c\\u8001\\u5e74\\u4eba\\u559c\\u6b22\\u7684\\u517b\\u8001\\u65b9\\u5f0f\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                0.1,\n",
       "                0.2,\n",
       "                0.6,\n",
       "                1.3,\n",
       "                16.3,\n",
       "                39.3,\n",
       "                42.3\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"symbolSize\": 80,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"average\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"max\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"min\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e0d\\u540c\\u8001\\u5e74\\u4eba\\u559c\\u6b22\\u7684\\u517b\\u8001\\u65b9\\u5f0f\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0d\\u540c\\u8001\\u5e74\\u4eba\\u559c\\u6b22\\u7684\\u517b\\u8001\\u65b9\\u5f0f\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u5546\\u4e1a\\u6027\\u8001\\u5e74\\u516c\\u5bd3\",\n",
       "                \"\\u6751\\u91cc\\u7684\\u65e5\\u6258\\u6240\",\n",
       "                \"\\u5176\\u4ed6\",\n",
       "                \"\\u656c\\u8001\\u9662\\u3001\\u798f\\u5229\\u9662\",\n",
       "                \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u5728\\u4e0d\\u5728\\u9644\\u8fd1\",\n",
       "                \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u6700\\u597d\\u4f4f\\u5728\\u9644\\u8fd1\",\n",
       "                \"\\u4e0e\\u5b50\\u5973\\u4e00\\u8d77\\u5c45\\u4f4f\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e0d\\u540c\\u8001\\u5e74\\u4eba\\u559c\\u6b22\\u7684\\u517b\\u8001\\u65b9\\u5f0f\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_959d83cc220843dc84315bdacfc72b02.setOption(option_959d83cc220843dc84315bdacfc72b02);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be5e48190>"
      ]
     },
     "execution_count": 163,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 条形图\n",
    "import random\n",
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Bar\n",
    "\n",
    "x=fangshi[\"喜欢的养老方式\"]\n",
    "x1=list(x)\n",
    "x1.reverse()\n",
    "x1\n",
    "\n",
    "y=fangshi[\"合计\"]\n",
    "y1=list(y)\n",
    "y1.reverse()\n",
    "y1\n",
    "\n",
    "x_vals1 = x1\n",
    "y_vals = y1\n",
    "bar = Bar().add_xaxis(x_vals1)      \n",
    "bar.add_yaxis('不同老年人喜欢的养老方式', y_vals, \n",
    "               markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_='average'),\n",
    "                                                 opts.MarkPointItem(type_='max'),\n",
    "                                                 opts.MarkPointItem(type_='min')], \n",
    "                                                symbol_size=80)\n",
    "              ) \n",
    "bar.set_series_opts(label_opts=opts.LabelOpts(is_show=True, position='right'))\n",
    "bar.set_global_opts(title_opts=opts.TitleOpts(title='不同老年人喜欢的养老方式'))\n",
    "bar.reversal_axis() #翻转XY轴，将柱状图转换为条形图\n",
    "bar.render_notebook()\n",
    "# bar.render('条形图.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e025d4a9",
   "metadata": {},
   "source": [
    "### 漏斗图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 208,
   "id": "3cf17200",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"a51146b3409e4a38aa7f2dab3e93f8a2\" style=\"width:1000px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_a51146b3409e4a38aa7f2dab3e93f8a2 = echarts.init(\n",
       "                    document.getElementById('a51146b3409e4a38aa7f2dab3e93f8a2'), 'white', {renderer: 'canvas'});\n",
       "                var option_a51146b3409e4a38aa7f2dab3e93f8a2 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"funnel\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u4e0e\\u5b50\\u5973\\u4e00\\u8d77\\u5c45\\u4f4f\",\n",
       "                    \"value\": 42.3\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u6700\\u597d\\u4f4f\\u5728\\u9644\\u8fd1\",\n",
       "                    \"value\": 39.3\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u5728\\u4e0d\\u5728\\u9644\\u8fd1\",\n",
       "                    \"value\": 16.3\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u656c\\u8001\\u9662\\u3001\\u798f\\u5229\\u9662\",\n",
       "                    \"value\": 1.3\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5176\\u4ed6\",\n",
       "                    \"value\": 0.6\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6751\\u91cc\\u7684\\u65e5\\u6258\\u6240\",\n",
       "                    \"value\": 0.2\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5546\\u4e1a\\u6027\\u8001\\u5e74\\u516c\\u5bd3\",\n",
       "                    \"value\": 0.1\n",
       "                }\n",
       "            ],\n",
       "            \"sort\": \"descending\",\n",
       "            \"gap\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"inside\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"formatter\": \"{a} <br/>{b} : {c}%\",\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"itemStyle\": {\n",
       "                \"borderColor\": \"#fff\",\n",
       "                \"borderWidth\": 1\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u6751\\u91cc\\u7684\\u65e5\\u6258\\u6240\",\n",
       "                \"\\u5546\\u4e1a\\u6027\\u8001\\u5e74\\u516c\\u5bd3\",\n",
       "                \"\\u5176\\u4ed6\",\n",
       "                \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u6700\\u597d\\u4f4f\\u5728\\u9644\\u8fd1\",\n",
       "                \"\\u656c\\u8001\\u9662\\u3001\\u798f\\u5229\\u9662\",\n",
       "                \"\\u4e0e\\u5b50\\u5973\\u4e00\\u8d77\\u5c45\\u4f4f\",\n",
       "                \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u5728\\u4e0d\\u5728\\u9644\\u8fd1\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0e\\u5b50\\u5973\\u4e00\\u8d77\\u5c45\\u4f4f\": true,\n",
       "                \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u6700\\u597d\\u4f4f\\u5728\\u9644\\u8fd1\": true,\n",
       "                \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u5728\\u4e0d\\u5728\\u9644\\u8fd1\": true,\n",
       "                \"\\u656c\\u8001\\u9662\\u3001\\u798f\\u5229\\u9662\": true,\n",
       "                \"\\u5176\\u4ed6\": true,\n",
       "                \"\\u6751\\u91cc\\u7684\\u65e5\\u6258\\u6240\": true,\n",
       "                \"\\u5546\\u4e1a\\u6027\\u8001\\u5e74\\u516c\\u5bd3\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6f0f\\u6597\\u56fe\",\n",
       "            \"subtext\": \"\\u7eaf\\u5c5e\\u865a\\u6784\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_a51146b3409e4a38aa7f2dab3e93f8a2.setOption(option_a51146b3409e4a38aa7f2dab3e93f8a2);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be6005880>"
      ]
     },
     "execution_count": 208,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Funnel\n",
    "#xy轴数据\n",
    "x=fangshi[\"喜欢的养老方式\"]\n",
    "x1=list(x)\n",
    "\n",
    "y=fangshi[\"合计\"]\n",
    "y1=list(y)\n",
    "# x_data = [\"展现\", \"点击\", \"访问\", \"咨询\", \"订单\"]\n",
    "# y_data = [100, 80, 60, 40, 20]\n",
    "\n",
    "data = [[x1[i], y1[i]] for i in range(len(x1))]\n",
    "\n",
    "(\n",
    "    Funnel(init_opts=opts.InitOpts(width=\"1000px\", height=\"500px\"))\n",
    "    .add(\n",
    "        series_name=\"\",\n",
    "        data_pair=data,\n",
    "        gap=2,\n",
    "        tooltip_opts=opts.TooltipOpts(trigger=\"item\", formatter=\"{a} <br/>{b} : {c}%\"),\n",
    "        label_opts=opts.LabelOpts(is_show=True, position=\"inside\"),\n",
    "        itemstyle_opts=opts.ItemStyleOpts(border_color=\"#fff\", border_width=1),\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"漏斗图\", subtitle=\"纯属虚构\"))\n",
    "#     .render(\"funnel_chart.html\")\n",
    "   .render_notebook()\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1507470b",
   "metadata": {},
   "source": [
    "## 老年人口最担忧的养老问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 213,
   "id": "8d2b2254",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>担忧的问题</th>\n",
       "      <th>占比（%）</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>医疗费</td>\n",
       "      <td>59.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>大病未及时发现治疗</td>\n",
       "      <td>48.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>缺乏护理、治疗</td>\n",
       "      <td>29.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>日常生活困难</td>\n",
       "      <td>20.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>亲人团聚少</td>\n",
       "      <td>19.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>社交人情冷落</td>\n",
       "      <td>14.3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       担忧的问题  占比（%）\n",
       "0        医疗费   59.5\n",
       "1  大病未及时发现治疗   48.7\n",
       "2    缺乏护理、治疗   29.3\n",
       "3     日常生活困难   20.9\n",
       "4      亲人团聚少   19.6\n",
       "5     社交人情冷落   14.3"
      ]
     },
     "execution_count": 213,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wenti=pd.read_excel('data/最担忧的养老问题占比.xlsx',\n",
    "                        sheet_name='数据'\n",
    "                     )\n",
    "wenti"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "72c87f85",
   "metadata": {},
   "source": [
    "### 漏斗图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 218,
   "id": "8cef073f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"de9b042550f046148f7cc952f13c4484\" style=\"width:1000px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_de9b042550f046148f7cc952f13c4484 = echarts.init(\n",
       "                    document.getElementById('de9b042550f046148f7cc952f13c4484'), 'white', {renderer: 'canvas'});\n",
       "                var option_de9b042550f046148f7cc952f13c4484 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"funnel\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u533b\\u7597\\u8d39\",\n",
       "                    \"value\": 59.5\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5927\\u75c5\\u672a\\u53ca\\u65f6\\u53d1\\u73b0\\u6cbb\\u7597\",\n",
       "                    \"value\": 48.7\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7f3a\\u4e4f\\u62a4\\u7406\\u3001\\u6cbb\\u7597\",\n",
       "                    \"value\": 29.3\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65e5\\u5e38\\u751f\\u6d3b\\u56f0\\u96be\",\n",
       "                    \"value\": 20.9\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4eb2\\u4eba\\u56e2\\u805a\\u5c11\",\n",
       "                    \"value\": 19.6\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u793e\\u4ea4\\u4eba\\u60c5\\u51b7\\u843d\",\n",
       "                    \"value\": 14.3\n",
       "                }\n",
       "            ],\n",
       "            \"sort\": \"descending\",\n",
       "            \"gap\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"inside\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"formatter\": \"{a} <br/>{b} : {c}%\",\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"itemStyle\": {\n",
       "                \"borderColor\": \"#fff\",\n",
       "                \"borderWidth\": 1\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u793e\\u4ea4\\u4eba\\u60c5\\u51b7\\u843d\",\n",
       "                \"\\u65e5\\u5e38\\u751f\\u6d3b\\u56f0\\u96be\",\n",
       "                \"\\u7f3a\\u4e4f\\u62a4\\u7406\\u3001\\u6cbb\\u7597\",\n",
       "                \"\\u533b\\u7597\\u8d39\",\n",
       "                \"\\u5927\\u75c5\\u672a\\u53ca\\u65f6\\u53d1\\u73b0\\u6cbb\\u7597\",\n",
       "                \"\\u4eb2\\u4eba\\u56e2\\u805a\\u5c11\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u533b\\u7597\\u8d39\": true,\n",
       "                \"\\u5927\\u75c5\\u672a\\u53ca\\u65f6\\u53d1\\u73b0\\u6cbb\\u7597\": true,\n",
       "                \"\\u7f3a\\u4e4f\\u62a4\\u7406\\u3001\\u6cbb\\u7597\": true,\n",
       "                \"\\u65e5\\u5e38\\u751f\\u6d3b\\u56f0\\u96be\": true,\n",
       "                \"\\u4eb2\\u4eba\\u56e2\\u805a\\u5c11\": true,\n",
       "                \"\\u793e\\u4ea4\\u4eba\\u60c5\\u51b7\\u843d\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u517b\\u8001\\u62c5\\u5fe7\\u7684\\u95ee\\u9898\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_de9b042550f046148f7cc952f13c4484.setOption(option_de9b042550f046148f7cc952f13c4484);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be60a7550>"
      ]
     },
     "execution_count": 218,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Funnel\n",
    "#xy轴数据\n",
    "x=wenti[\"担忧的问题\"]\n",
    "x1=list(x)\n",
    "\n",
    "y=wenti[\"占比（%）\"]\n",
    "y1=list(y)\n",
    "# x_data = [\"展现\", \"点击\", \"访问\", \"咨询\", \"订单\"]\n",
    "# y_data = [100, 80, 60, 40, 20]\n",
    "\n",
    "data = [[x1[i], y1[i]] for i in range(len(x1))]\n",
    "\n",
    "(\n",
    "    Funnel(init_opts=opts.InitOpts(width=\"1000px\", height=\"500px\"))\n",
    "    .add(\n",
    "        series_name=\"\",\n",
    "        data_pair=data,\n",
    "        gap=2,\n",
    "        tooltip_opts=opts.TooltipOpts(trigger=\"item\", formatter=\"{a} <br/>{b} : {c}%\"),\n",
    "        label_opts=opts.LabelOpts(is_show=True, position=\"inside\"),\n",
    "        itemstyle_opts=opts.ItemStyleOpts(border_color=\"#fff\", border_width=1),\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"养老担忧的问题\"))\n",
    "#     .render(\"html/养老担忧问题.html\")\n",
    "   .render_notebook()\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "130edfab",
   "metadata": {},
   "source": [
    "# 养老机构"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d7f3d3c3",
   "metadata": {},
   "source": [
    "## 不同价格段养老机构"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "9e46a8f5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>价格段</th>\n",
       "      <th>养老机构占比(%)</th>\n",
       "      <th>Unnamed: 2</th>\n",
       "      <th>Unnamed: 3</th>\n",
       "      <th>Unnamed: 4</th>\n",
       "      <th>Unnamed: 5</th>\n",
       "      <th>Unnamed: 6</th>\n",
       "      <th>Unnamed: 7</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>500-1000元/月</td>\n",
       "      <td>89.42</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1001-2000元/月</td>\n",
       "      <td>12.51</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2001-2500元/月</td>\n",
       "      <td>7.47</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2501-3000元/月</td>\n",
       "      <td>6.95</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>3001-5000元/月</td>\n",
       "      <td>5.88</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5001-10000元/月</td>\n",
       "      <td>2.71</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>10000以上元/月</td>\n",
       "      <td>0.56</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             价格段  养老机构占比(%)  Unnamed: 2  Unnamed: 3  Unnamed: 4  Unnamed: 5  \\\n",
       "0    500-1000元/月      89.42         NaN         NaN         NaN         NaN   \n",
       "1   1001-2000元/月      12.51         NaN         NaN         NaN         NaN   \n",
       "2   2001-2500元/月       7.47         NaN         NaN         NaN         NaN   \n",
       "3   2501-3000元/月       6.95         NaN         NaN         NaN         NaN   \n",
       "4   3001-5000元/月       5.88         NaN         NaN         NaN         NaN   \n",
       "5  5001-10000元/月       2.71         NaN         NaN         NaN         NaN   \n",
       "6     10000以上元/月       0.56         NaN         NaN         NaN         NaN   \n",
       "\n",
       "   Unnamed: 6  Unnamed: 7  \n",
       "0         NaN         NaN  \n",
       "1         NaN         NaN  \n",
       "2         NaN         NaN  \n",
       "3         NaN         NaN  \n",
       "4         NaN         NaN  \n",
       "5         NaN         NaN  \n",
       "6         NaN         NaN  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "jiage = pd.read_csv('data/不同价格段养老机构.csv',encoding=\"gbk\")\n",
    "jiage"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0b6f674b",
   "metadata": {},
   "source": [
    "### 条形图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "480db313",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"2e8dfba6ab314e7b93ceca6da8e64ed2\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_2e8dfba6ab314e7b93ceca6da8e64ed2 = echarts.init(\n",
       "                    document.getElementById('2e8dfba6ab314e7b93ceca6da8e64ed2'), 'white', {renderer: 'canvas'});\n",
       "                var option_2e8dfba6ab314e7b93ceca6da8e64ed2 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                0.56,\n",
       "                2.71,\n",
       "                5.88,\n",
       "                6.95,\n",
       "                7.47,\n",
       "                12.51,\n",
       "                89.42\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"symbolSize\": 80,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"average\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"max\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"min\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u8001\\u5e74\\u4eba\\u53e3\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"10000\\u4ee5\\u4e0a\\u5143/\\u6708\",\n",
       "                \"5001-10000\\u5143/\\u6708\",\n",
       "                \"3001-5000\\u5143/\\u6708\",\n",
       "                \"2501-3000\\u5143/\\u6708\",\n",
       "                \"2001-2500\\u5143/\\u6708\",\n",
       "                \"1001-2000\\u5143/\\u6708\",\n",
       "                \"500-1000\\u5143/\\u6708\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e2d\\u56fd\\u4eba\\u53e3\\u8001\\u9f84\\u5316\\u5730\\u533a\\u5206\\u5e03\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_2e8dfba6ab314e7b93ceca6da8e64ed2.setOption(option_2e8dfba6ab314e7b93ceca6da8e64ed2);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be556e6d0>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 条形图\n",
    "import random\n",
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Bar\n",
    "\n",
    "x=jiage[\"价格段\"]\n",
    "x1=list(x)\n",
    "x1.reverse()\n",
    "x1\n",
    "\n",
    "y=jiage[\"养老机构占比(%)\"]\n",
    "y1=list(y)\n",
    "y1.reverse()\n",
    "y1\n",
    "\n",
    "x_vals1 = x1\n",
    "y_vals = y1\n",
    "bar = Bar().add_xaxis(x_vals1)      \n",
    "bar.add_yaxis('不同省份的老年人口', y_vals, \n",
    "               markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_='average'),\n",
    "                                                 opts.MarkPointItem(type_='max'),\n",
    "                                                 opts.MarkPointItem(type_='min')], \n",
    "                                                symbol_size=80)\n",
    "              ) \n",
    "bar.set_series_opts(label_opts=opts.LabelOpts(is_show=True, position='right'))\n",
    "bar.set_global_opts(title_opts=opts.TitleOpts(title='中国人口老龄化地区分布'))\n",
    "bar.reversal_axis() #翻转XY轴，将柱状图转换为条形图\n",
    "bar.render_notebook()\n",
    "# bar.render('条形图.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aed38562",
   "metadata": {},
   "source": [
    "### 柱形图（√）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "75e2b6a2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"c530a0dfa0a14839bba05a399cc69f3a\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_c530a0dfa0a14839bba05a399cc69f3a = echarts.init(\n",
       "                    document.getElementById('c530a0dfa0a14839bba05a399cc69f3a'), 'white', {renderer: 'canvas'});\n",
       "                var option_c530a0dfa0a14839bba05a399cc69f3a = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e0d\\u540c\\u517b\\u8001\\u673a\\u6784\\u670d\\u52a1\\u4ef7\\u683c\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                89.42,\n",
       "                12.51,\n",
       "                7.47,\n",
       "                6.95,\n",
       "                5.88,\n",
       "                2.71,\n",
       "                0.56\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e0d\\u540c\\u517b\\u8001\\u673a\\u6784\\u670d\\u52a1\\u4ef7\\u683c\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0d\\u540c\\u517b\\u8001\\u673a\\u6784\\u670d\\u52a1\\u4ef7\\u683c\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"500-1000\\u5143/\\u6708\",\n",
       "                \"1001-2000\\u5143/\\u6708\",\n",
       "                \"2001-2500\\u5143/\\u6708\",\n",
       "                \"2501-3000\\u5143/\\u6708\",\n",
       "                \"3001-5000\\u5143/\\u6708\",\n",
       "                \"5001-10000\\u5143/\\u6708\",\n",
       "                \"10000\\u4ee5\\u4e0a\\u5143/\\u6708\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e0d\\u540c\\u517b\\u8001\\u673a\\u6784\\u670d\\u52a1\\u4ef7\\u683c\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false,\n",
       "        \"filterMode\": \"filter\"\n",
       "    }\n",
       "};\n",
       "                chart_c530a0dfa0a14839bba05a399cc69f3a.setOption(option_c530a0dfa0a14839bba05a399cc69f3a);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be5583a60>"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts.charts import Bar\n",
    "#xy轴数据\n",
    "x= jiage[\"价格段\"]\n",
    "x1=list(x)\n",
    "\n",
    "y=jiage[\"养老机构占比(%)\"]\n",
    "y1=list(y)\n",
    "\n",
    "#柱形图\n",
    "l1=x1\n",
    "l2=y1\n",
    "bar = (\n",
    "    Bar()\n",
    "    .add_xaxis(l1)\n",
    "    .add_yaxis(\"不同养老机构服务价格\", l2)\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"不同养老机构服务价格\"),\n",
    "                     datazoom_opts=opts.DataZoomOpts(type_=\"slider\"))\n",
    ")\n",
    "bar.render_notebook()\n",
    "# bar.render('html/不同养老机构服务价格.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e5bb8468",
   "metadata": {},
   "source": [
    "### 饼图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "427171c8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"ff83fa0d7e8e44fcb6d13a07c3ee0c41\" style=\"width:1600px; height:800px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_ff83fa0d7e8e44fcb6d13a07c3ee0c41 = echarts.init(\n",
       "                    document.getElementById('ff83fa0d7e8e44fcb6d13a07c3ee0c41'), 'white', {renderer: 'canvas'});\n",
       "                var option_ff83fa0d7e8e44fcb6d13a07c3ee0c41 = {\n",
       "    \"backgroundColor\": \"#2c343c\",\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"name\": \"\\u8bbf\\u95ee\\u6765\\u6e90\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"10000\\u4ee5\\u4e0a\\u5143/\\u6708\",\n",
       "                    \"value\": 0.56\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"5001-10000\\u5143/\\u6708\",\n",
       "                    \"value\": 2.71\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"3001-5000\\u5143/\\u6708\",\n",
       "                    \"value\": 5.88\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2501-3000\\u5143/\\u6708\",\n",
       "                    \"value\": 6.95\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2001-2500\\u5143/\\u6708\",\n",
       "                    \"value\": 7.47\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"1001-2000\\u5143/\\u6708\",\n",
       "                    \"value\": 12.51\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"500-1000\\u5143/\\u6708\",\n",
       "                    \"value\": 89.42\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": \"55%\",\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"roseType\": \"radius\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"color\": \"rgba(255, 255, 255, 0.3)\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"formatter\": \"{a} <br/>{b}: {c} ({d}%)\",\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"10000\\u4ee5\\u4e0a\\u5143/\\u6708\",\n",
       "                \"5001-10000\\u5143/\\u6708\",\n",
       "                \"3001-5000\\u5143/\\u6708\",\n",
       "                \"2501-3000\\u5143/\\u6708\",\n",
       "                \"2001-2500\\u5143/\\u6708\",\n",
       "                \"1001-2000\\u5143/\\u6708\",\n",
       "                \"500-1000\\u5143/\\u6708\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": false,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Customized Pie\",\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"20\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textStyle\": {\n",
       "                \"color\": \"#fff\"\n",
       "            }\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_ff83fa0d7e8e44fcb6d13a07c3ee0c41.setOption(option_ff83fa0d7e8e44fcb6d13a07c3ee0c41);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be556f520>"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Pie\n",
    "#xy轴数据\n",
    "x_data=jiage[\"价格段\"]\n",
    "x_data=list(x_data)\n",
    "\n",
    "y_data=jiage[\"养老机构占比(%)\"]\n",
    "y_data=list(y_data)\n",
    "\n",
    "# x_data = [\"直接访问\", \"邮件营销\", \"联盟广告\", \"视频广告\", \"搜索引擎\"]\n",
    "# y_data = [335, 310, 274, 235, 400]\n",
    "data_pair = [list(z) for z in zip(x_data, y_data)]\n",
    "data_pair.sort(key=lambda x: x[1])\n",
    "\n",
    "(\n",
    "    Pie(init_opts=opts.InitOpts(width=\"1600px\", height=\"800px\", bg_color=\"#2c343c\"))\n",
    "    .add(\n",
    "        series_name=\"访问来源\",\n",
    "        data_pair=data_pair,\n",
    "        rosetype=\"radius\",\n",
    "        radius=\"55%\",\n",
    "        center=[\"50%\", \"50%\"],\n",
    "        label_opts=opts.LabelOpts(is_show=False, position=\"center\"),\n",
    "    )\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(\n",
    "            title=\"Customized Pie\",\n",
    "            pos_left=\"center\",\n",
    "            pos_top=\"20\",\n",
    "            title_textstyle_opts=opts.TextStyleOpts(color=\"#fff\"),\n",
    "        ),\n",
    "        legend_opts=opts.LegendOpts(is_show=False),\n",
    "    )\n",
    "    .set_series_opts(\n",
    "        tooltip_opts=opts.TooltipOpts(\n",
    "            trigger=\"item\", formatter=\"{a} <br/>{b}: {c} ({d}%)\"\n",
    "        ),\n",
    "        label_opts=opts.LabelOpts(color=\"rgba(255, 255, 255, 0.3)\"),\n",
    "    )\n",
    "#     .render(\"customized_pie.html\")\n",
    "    .render_notebook()\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9dd66d4e",
   "metadata": {},
   "source": [
    "## 不同地区养老机构"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "8463fa23",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>省份</th>\n",
       "      <th>养老机构(个)</th>\n",
       "      <th>养老机构床位数(万张)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>河南省</td>\n",
       "      <td>3340</td>\n",
       "      <td>335165</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>安徽省</td>\n",
       "      <td>2596</td>\n",
       "      <td>377487</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>四川省</td>\n",
       "      <td>2504</td>\n",
       "      <td>297964</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>江苏省</td>\n",
       "      <td>2494</td>\n",
       "      <td>439914</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>湖南省</td>\n",
       "      <td>2417</td>\n",
       "      <td>261817</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>山东省</td>\n",
       "      <td>2271</td>\n",
       "      <td>380438</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>辽宁省</td>\n",
       "      <td>2171</td>\n",
       "      <td>183863</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>黑龙江省</td>\n",
       "      <td>2055</td>\n",
       "      <td>176705</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>湖北省</td>\n",
       "      <td>1968</td>\n",
       "      <td>283738</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>广东省</td>\n",
       "      <td>1958</td>\n",
       "      <td>247579</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>江西省</td>\n",
       "      <td>1854</td>\n",
       "      <td>176526</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>河北省</td>\n",
       "      <td>1782</td>\n",
       "      <td>238320</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>浙江省</td>\n",
       "      <td>1678</td>\n",
       "      <td>266521</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>吉林省</td>\n",
       "      <td>1520</td>\n",
       "      <td>141744</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>重庆市</td>\n",
       "      <td>1146</td>\n",
       "      <td>121983</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>贵州省</td>\n",
       "      <td>968</td>\n",
       "      <td>84629</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>云南省</td>\n",
       "      <td>903</td>\n",
       "      <td>92234</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>山西省</td>\n",
       "      <td>774</td>\n",
       "      <td>85829</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>陕西省</td>\n",
       "      <td>763</td>\n",
       "      <td>108086</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>福建省</td>\n",
       "      <td>762</td>\n",
       "      <td>106798</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>上海市</td>\n",
       "      <td>681</td>\n",
       "      <td>147671</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>内蒙古自治区</td>\n",
       "      <td>665</td>\n",
       "      <td>78229</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>广西壮族自治区</td>\n",
       "      <td>588</td>\n",
       "      <td>85500</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>北京市</td>\n",
       "      <td>571</td>\n",
       "      <td>108640</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>天津市</td>\n",
       "      <td>407</td>\n",
       "      <td>60149</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>新疆维吾尔自治区</td>\n",
       "      <td>396</td>\n",
       "      <td>51477</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>甘肃省</td>\n",
       "      <td>278</td>\n",
       "      <td>30421</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>宁夏回族自治区</td>\n",
       "      <td>131</td>\n",
       "      <td>25224</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>青海省</td>\n",
       "      <td>64</td>\n",
       "      <td>6440</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>海南省</td>\n",
       "      <td>59</td>\n",
       "      <td>8695</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>西藏自治区</td>\n",
       "      <td>53</td>\n",
       "      <td>6399</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          省份  养老机构(个)  养老机构床位数(万张)\n",
       "0        河南省     3340       335165\n",
       "1        安徽省     2596       377487\n",
       "2        四川省     2504       297964\n",
       "3        江苏省     2494       439914\n",
       "4        湖南省     2417       261817\n",
       "5        山东省     2271       380438\n",
       "6        辽宁省     2171       183863\n",
       "7       黑龙江省     2055       176705\n",
       "8        湖北省     1968       283738\n",
       "9        广东省     1958       247579\n",
       "10       江西省     1854       176526\n",
       "11       河北省     1782       238320\n",
       "12       浙江省     1678       266521\n",
       "13       吉林省     1520       141744\n",
       "14       重庆市     1146       121983\n",
       "15       贵州省      968        84629\n",
       "16       云南省      903        92234\n",
       "17       山西省      774        85829\n",
       "18       陕西省      763       108086\n",
       "19       福建省      762       106798\n",
       "20       上海市      681       147671\n",
       "21    内蒙古自治区      665        78229\n",
       "22   广西壮族自治区      588        85500\n",
       "23       北京市      571       108640\n",
       "24       天津市      407        60149\n",
       "25  新疆维吾尔自治区      396        51477\n",
       "26       甘肃省      278        30421\n",
       "27   宁夏回族自治区      131        25224\n",
       "28       青海省       64         6440\n",
       "29       海南省       59         8695\n",
       "30     西藏自治区       53         6399"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "jigou = pd.read_csv('data/不同地区养老机构.csv',encoding=\"utf-8\")\n",
    "jigou"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "03486c68",
   "metadata": {},
   "source": [
    "### 柱形图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "85e0447d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"81303444bf3944928b25727251fb68e1\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_81303444bf3944928b25727251fb68e1 = echarts.init(\n",
       "                    document.getElementById('81303444bf3944928b25727251fb68e1'), 'white', {renderer: 'canvas'});\n",
       "                var option_81303444bf3944928b25727251fb68e1 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e0d\\u540c\\u517b\\u8001\\u673a\\u6784\\u670d\\u52a1\\u4ef7\\u683c\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                3340,\n",
       "                2596,\n",
       "                2504,\n",
       "                2494,\n",
       "                2417,\n",
       "                2271,\n",
       "                2171,\n",
       "                2055,\n",
       "                1968,\n",
       "                1958,\n",
       "                1854,\n",
       "                1782,\n",
       "                1678,\n",
       "                1520,\n",
       "                1146,\n",
       "                968,\n",
       "                903,\n",
       "                774,\n",
       "                763,\n",
       "                762,\n",
       "                681,\n",
       "                665,\n",
       "                588,\n",
       "                571,\n",
       "                407,\n",
       "                396,\n",
       "                278,\n",
       "                131,\n",
       "                64,\n",
       "                59,\n",
       "                53\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e0d\\u540c\\u517b\\u8001\\u673a\\u6784\\u670d\\u52a1\\u4ef7\\u683c\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0d\\u540c\\u517b\\u8001\\u673a\\u6784\\u670d\\u52a1\\u4ef7\\u683c\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u6cb3\\u5357\\u7701\",\n",
       "                \"\\u5b89\\u5fbd\\u7701\",\n",
       "                \"\\u56db\\u5ddd\\u7701\",\n",
       "                \"\\u6c5f\\u82cf\\u7701\",\n",
       "                \"\\u6e56\\u5357\\u7701\",\n",
       "                \"\\u5c71\\u4e1c\\u7701\",\n",
       "                \"\\u8fbd\\u5b81\\u7701\",\n",
       "                \"\\u9ed1\\u9f99\\u6c5f\\u7701\",\n",
       "                \"\\u6e56\\u5317\\u7701\",\n",
       "                \"\\u5e7f\\u4e1c\\u7701\",\n",
       "                \"\\u6c5f\\u897f\\u7701\",\n",
       "                \"\\u6cb3\\u5317\\u7701\",\n",
       "                \"\\u6d59\\u6c5f\\u7701\",\n",
       "                \"\\u5409\\u6797\\u7701\",\n",
       "                \"\\u91cd\\u5e86\\u5e02\",\n",
       "                \"\\u8d35\\u5dde\\u7701\",\n",
       "                \"\\u4e91\\u5357\\u7701\",\n",
       "                \"\\u5c71\\u897f\\u7701\",\n",
       "                \"\\u9655\\u897f\\u7701\",\n",
       "                \"\\u798f\\u5efa\\u7701\",\n",
       "                \"\\u4e0a\\u6d77\\u5e02\",\n",
       "                \"\\u5185\\u8499\\u53e4\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u5e7f\\u897f\\u58ee\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u5317\\u4eac\\u5e02\",\n",
       "                \"\\u5929\\u6d25\\u5e02\",\n",
       "                \"\\u65b0\\u7586\\u7ef4\\u543e\\u5c14\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u7518\\u8083\\u7701\",\n",
       "                \"\\u5b81\\u590f\\u56de\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u9752\\u6d77\\u7701\",\n",
       "                \"\\u6d77\\u5357\\u7701\",\n",
       "                \"\\u897f\\u85cf\\u81ea\\u6cbb\\u533a\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e0d\\u540c\\u517b\\u8001\\u673a\\u6784\\u670d\\u52a1\\u4ef7\\u683c\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false,\n",
       "        \"filterMode\": \"filter\"\n",
       "    }\n",
       "};\n",
       "                chart_81303444bf3944928b25727251fb68e1.setOption(option_81303444bf3944928b25727251fb68e1);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be5583340>"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts.charts import Bar\n",
    "#xy轴数据\n",
    "x= jigou['省份']\n",
    "x1=list(x)\n",
    "\n",
    "y=jigou['养老机构(个)']\n",
    "y1=list(y)\n",
    "\n",
    "#柱形图\n",
    "l1=x1\n",
    "l2=y1\n",
    "bar = (\n",
    "    Bar()\n",
    "    .add_xaxis(l1)\n",
    "    .add_yaxis(\"不同养老机构服务价格\", l2)\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"不同养老机构服务价格\"),\n",
    "                     datazoom_opts=opts.DataZoomOpts(type_=\"slider\"))\n",
    ")\n",
    "bar.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f57a7f44",
   "metadata": {},
   "source": [
    "### 条形图（√）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "61ff2482",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"f4619f2e71d348eba94a75963eb21d57\" style=\"width:1200px; height:800px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_f4619f2e71d348eba94a75963eb21d57 = echarts.init(\n",
       "                    document.getElementById('f4619f2e71d348eba94a75963eb21d57'), 'white', {renderer: 'canvas'});\n",
       "                var option_f4619f2e71d348eba94a75963eb21d57 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                53,\n",
       "                59,\n",
       "                64,\n",
       "                131,\n",
       "                278,\n",
       "                396,\n",
       "                407,\n",
       "                571,\n",
       "                588,\n",
       "                665,\n",
       "                681,\n",
       "                762,\n",
       "                763,\n",
       "                774,\n",
       "                903,\n",
       "                968,\n",
       "                1146,\n",
       "                1520,\n",
       "                1678,\n",
       "                1782,\n",
       "                1854,\n",
       "                1958,\n",
       "                1968,\n",
       "                2055,\n",
       "                2171,\n",
       "                2271,\n",
       "                2417,\n",
       "                2494,\n",
       "                2504,\n",
       "                2596,\n",
       "                3340\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"right\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"symbolSize\": 80,\n",
       "                \"label\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"color\": \"#fff\",\n",
       "                    \"margin\": 8\n",
       "                },\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"average\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"max\"\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"min\"\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"\\u897f\\u85cf\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u6d77\\u5357\\u7701\",\n",
       "                \"\\u9752\\u6d77\\u7701\",\n",
       "                \"\\u5b81\\u590f\\u56de\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u7518\\u8083\\u7701\",\n",
       "                \"\\u65b0\\u7586\\u7ef4\\u543e\\u5c14\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u5929\\u6d25\\u5e02\",\n",
       "                \"\\u5317\\u4eac\\u5e02\",\n",
       "                \"\\u5e7f\\u897f\\u58ee\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u5185\\u8499\\u53e4\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u4e0a\\u6d77\\u5e02\",\n",
       "                \"\\u798f\\u5efa\\u7701\",\n",
       "                \"\\u9655\\u897f\\u7701\",\n",
       "                \"\\u5c71\\u897f\\u7701\",\n",
       "                \"\\u4e91\\u5357\\u7701\",\n",
       "                \"\\u8d35\\u5dde\\u7701\",\n",
       "                \"\\u91cd\\u5e86\\u5e02\",\n",
       "                \"\\u5409\\u6797\\u7701\",\n",
       "                \"\\u6d59\\u6c5f\\u7701\",\n",
       "                \"\\u6cb3\\u5317\\u7701\",\n",
       "                \"\\u6c5f\\u897f\\u7701\",\n",
       "                \"\\u5e7f\\u4e1c\\u7701\",\n",
       "                \"\\u6e56\\u5317\\u7701\",\n",
       "                \"\\u9ed1\\u9f99\\u6c5f\\u7701\",\n",
       "                \"\\u8fbd\\u5b81\\u7701\",\n",
       "                \"\\u5c71\\u4e1c\\u7701\",\n",
       "                \"\\u6e56\\u5357\\u7701\",\n",
       "                \"\\u6c5f\\u82cf\\u7701\",\n",
       "                \"\\u56db\\u5ddd\\u7701\",\n",
       "                \"\\u5b89\\u5fbd\\u7701\",\n",
       "                \"\\u6cb3\\u5357\\u7701\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e0d\\u540c\\u7701\\u4efd\\u7684\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_f4619f2e71d348eba94a75963eb21d57.setOption(option_f4619f2e71d348eba94a75963eb21d57);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be548a370>"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 条形图\n",
    "import random\n",
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Bar\n",
    "\n",
    "x=jigou['省份']\n",
    "x1=list(x)\n",
    "x1.reverse()\n",
    "\n",
    "y=jigou['养老机构(个)']\n",
    "y1=list(y)\n",
    "y1.reverse()\n",
    "\n",
    "x_vals1 = x1\n",
    "y_vals = y1\n",
    "bar = Bar(init_opts=opts.InitOpts(width=\"1200px\",height='800px')).add_xaxis(x_vals1)  \n",
    "bar.add_yaxis('不同省份的养老机构数量', y_vals, \n",
    "               markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_='average'),\n",
    "                                                 opts.MarkPointItem(type_='max'),\n",
    "                                                 opts.MarkPointItem(type_='min')], \n",
    "                                                symbol_size=80)\n",
    "              ) \n",
    "bar.set_series_opts(label_opts=opts.LabelOpts(is_show=True, position='right'))\n",
    "bar.set_global_opts(title_opts=opts.TitleOpts(title='不同省份的养老机构数量'))\n",
    "bar.reversal_axis() #翻转XY轴，将柱状图转换为条形图\n",
    "bar.render_notebook()\n",
    "# bar.render('html/不同省份老年机构数量.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "38896f87",
   "metadata": {},
   "source": [
    "### 漏斗图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "a94fbf75",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"fd770442043d4c0cb9b65e22dfd9b233\" style=\"width:1000px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_fd770442043d4c0cb9b65e22dfd9b233 = echarts.init(\n",
       "                    document.getElementById('fd770442043d4c0cb9b65e22dfd9b233'), 'white', {renderer: 'canvas'});\n",
       "                var option_fd770442043d4c0cb9b65e22dfd9b233 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"funnel\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5357\\u7701\",\n",
       "                    \"value\": 3340\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b89\\u5fbd\\u7701\",\n",
       "                    \"value\": 2596\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u56db\\u5ddd\\u7701\",\n",
       "                    \"value\": 2504\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u82cf\\u7701\",\n",
       "                    \"value\": 2494\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5357\\u7701\",\n",
       "                    \"value\": 2417\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u4e1c\\u7701\",\n",
       "                    \"value\": 2271\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8fbd\\u5b81\\u7701\",\n",
       "                    \"value\": 2171\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9ed1\\u9f99\\u6c5f\\u7701\",\n",
       "                    \"value\": 2055\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5317\\u7701\",\n",
       "                    \"value\": 1968\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u4e1c\\u7701\",\n",
       "                    \"value\": 1958\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u897f\\u7701\",\n",
       "                    \"value\": 1854\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5317\\u7701\",\n",
       "                    \"value\": 1782\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d59\\u6c5f\\u7701\",\n",
       "                    \"value\": 1678\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5409\\u6797\\u7701\",\n",
       "                    \"value\": 1520\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u91cd\\u5e86\\u5e02\",\n",
       "                    \"value\": 1146\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8d35\\u5dde\\u7701\",\n",
       "                    \"value\": 968\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e91\\u5357\\u7701\",\n",
       "                    \"value\": 903\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u897f\\u7701\",\n",
       "                    \"value\": 774\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9655\\u897f\\u7701\",\n",
       "                    \"value\": 763\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u798f\\u5efa\\u7701\",\n",
       "                    \"value\": 762\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e0a\\u6d77\\u5e02\",\n",
       "                    \"value\": 681\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5185\\u8499\\u53e4\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 665\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u897f\\u58ee\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 588\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5317\\u4eac\\u5e02\",\n",
       "                    \"value\": 571\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5929\\u6d25\\u5e02\",\n",
       "                    \"value\": 407\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65b0\\u7586\\u7ef4\\u543e\\u5c14\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 396\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7518\\u8083\\u7701\",\n",
       "                    \"value\": 278\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b81\\u590f\\u56de\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 131\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9752\\u6d77\\u7701\",\n",
       "                    \"value\": 64\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d77\\u5357\\u7701\",\n",
       "                    \"value\": 59\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u897f\\u85cf\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 53\n",
       "                }\n",
       "            ],\n",
       "            \"sort\": \"descending\",\n",
       "            \"gap\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"inside\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"formatter\": \"{a} <br/>{b} : {c}%\",\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"itemStyle\": {\n",
       "                \"borderColor\": \"#fff\",\n",
       "                \"borderWidth\": 1\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u9752\\u6d77\\u7701\",\n",
       "                \"\\u6d77\\u5357\\u7701\",\n",
       "                \"\\u65b0\\u7586\\u7ef4\\u543e\\u5c14\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u6e56\\u5357\\u7701\",\n",
       "                \"\\u5317\\u4eac\\u5e02\",\n",
       "                \"\\u56db\\u5ddd\\u7701\",\n",
       "                \"\\u798f\\u5efa\\u7701\",\n",
       "                \"\\u6e56\\u5317\\u7701\",\n",
       "                \"\\u5b81\\u590f\\u56de\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u9ed1\\u9f99\\u6c5f\\u7701\",\n",
       "                \"\\u6c5f\\u82cf\\u7701\",\n",
       "                \"\\u5409\\u6797\\u7701\",\n",
       "                \"\\u4e0a\\u6d77\\u5e02\",\n",
       "                \"\\u5b89\\u5fbd\\u7701\",\n",
       "                \"\\u5c71\\u4e1c\\u7701\",\n",
       "                \"\\u5185\\u8499\\u53e4\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u6cb3\\u5317\\u7701\",\n",
       "                \"\\u5e7f\\u897f\\u58ee\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u6cb3\\u5357\\u7701\",\n",
       "                \"\\u5e7f\\u4e1c\\u7701\",\n",
       "                \"\\u5929\\u6d25\\u5e02\",\n",
       "                \"\\u6d59\\u6c5f\\u7701\",\n",
       "                \"\\u91cd\\u5e86\\u5e02\",\n",
       "                \"\\u4e91\\u5357\\u7701\",\n",
       "                \"\\u7518\\u8083\\u7701\",\n",
       "                \"\\u8fbd\\u5b81\\u7701\",\n",
       "                \"\\u5c71\\u897f\\u7701\",\n",
       "                \"\\u6c5f\\u897f\\u7701\",\n",
       "                \"\\u897f\\u85cf\\u81ea\\u6cbb\\u533a\",\n",
       "                \"\\u8d35\\u5dde\\u7701\",\n",
       "                \"\\u9655\\u897f\\u7701\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u6cb3\\u5357\\u7701\": true,\n",
       "                \"\\u5b89\\u5fbd\\u7701\": true,\n",
       "                \"\\u56db\\u5ddd\\u7701\": true,\n",
       "                \"\\u6c5f\\u82cf\\u7701\": true,\n",
       "                \"\\u6e56\\u5357\\u7701\": true,\n",
       "                \"\\u5c71\\u4e1c\\u7701\": true,\n",
       "                \"\\u8fbd\\u5b81\\u7701\": true,\n",
       "                \"\\u9ed1\\u9f99\\u6c5f\\u7701\": true,\n",
       "                \"\\u6e56\\u5317\\u7701\": true,\n",
       "                \"\\u5e7f\\u4e1c\\u7701\": true,\n",
       "                \"\\u6c5f\\u897f\\u7701\": true,\n",
       "                \"\\u6cb3\\u5317\\u7701\": true,\n",
       "                \"\\u6d59\\u6c5f\\u7701\": true,\n",
       "                \"\\u5409\\u6797\\u7701\": true,\n",
       "                \"\\u91cd\\u5e86\\u5e02\": true,\n",
       "                \"\\u8d35\\u5dde\\u7701\": true,\n",
       "                \"\\u4e91\\u5357\\u7701\": true,\n",
       "                \"\\u5c71\\u897f\\u7701\": true,\n",
       "                \"\\u9655\\u897f\\u7701\": true,\n",
       "                \"\\u798f\\u5efa\\u7701\": true,\n",
       "                \"\\u4e0a\\u6d77\\u5e02\": true,\n",
       "                \"\\u5185\\u8499\\u53e4\\u81ea\\u6cbb\\u533a\": true,\n",
       "                \"\\u5e7f\\u897f\\u58ee\\u65cf\\u81ea\\u6cbb\\u533a\": true,\n",
       "                \"\\u5317\\u4eac\\u5e02\": true,\n",
       "                \"\\u5929\\u6d25\\u5e02\": true,\n",
       "                \"\\u65b0\\u7586\\u7ef4\\u543e\\u5c14\\u81ea\\u6cbb\\u533a\": true,\n",
       "                \"\\u7518\\u8083\\u7701\": true,\n",
       "                \"\\u5b81\\u590f\\u56de\\u65cf\\u81ea\\u6cbb\\u533a\": true,\n",
       "                \"\\u9752\\u6d77\\u7701\": true,\n",
       "                \"\\u6d77\\u5357\\u7701\": true,\n",
       "                \"\\u897f\\u85cf\\u81ea\\u6cbb\\u533a\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6f0f\\u6597\\u56fe\",\n",
       "            \"subtext\": \"\\u7eaf\\u5c5e\\u865a\\u6784\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_fd770442043d4c0cb9b65e22dfd9b233.setOption(option_fd770442043d4c0cb9b65e22dfd9b233);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be55a9190>"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Funnel\n",
    "#xy轴数据\n",
    "x= jigou['省份']\n",
    "x1=list(x)\n",
    "\n",
    "y=jigou['养老机构(个)']\n",
    "y1=list(y)\n",
    "# x_data = [\"展现\", \"点击\", \"访问\", \"咨询\", \"订单\"]\n",
    "# y_data = [100, 80, 60, 40, 20]\n",
    "\n",
    "data = [[x1[i], y1[i]] for i in range(len(x1))]\n",
    "\n",
    "(\n",
    "    Funnel(init_opts=opts.InitOpts(width=\"1000px\", height=\"500px\"))\n",
    "    .add(\n",
    "        series_name=\"\",\n",
    "        data_pair=data,\n",
    "        gap=2,\n",
    "        tooltip_opts=opts.TooltipOpts(trigger=\"item\", formatter=\"{a} <br/>{b} : {c}%\"),\n",
    "        label_opts=opts.LabelOpts(is_show=True, position=\"inside\"),\n",
    "        itemstyle_opts=opts.ItemStyleOpts(border_color=\"#fff\", border_width=1),\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"漏斗图\", subtitle=\"纯属虚构\"))\n",
    "#     .render(\"funnel_chart.html\")\n",
    "   .render_notebook()\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "16624adb",
   "metadata": {},
   "source": [
    "### 地图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "795188b8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'china':'https://assets.pyecharts.org/assets/maps/china'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"1dcbe18b29814c8a9005d40d50bf3856\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'china'], function(echarts) {\n",
       "                var chart_1dcbe18b29814c8a9005d40d50bf3856 = echarts.init(\n",
       "                    document.getElementById('1dcbe18b29814c8a9005d40d50bf3856'), 'white', {renderer: 'canvas'});\n",
       "                var option_1dcbe18b29814c8a9005d40d50bf3856 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"map\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"mapType\": \"china\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u4e1c\",\n",
       "                    \"value\": 6746757\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u56db\\u5ddd\",\n",
       "                    \"value\": 6710282\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u82cf\",\n",
       "                    \"value\": 6147499\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5357\",\n",
       "                    \"value\": 5754338\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u4e1c\",\n",
       "                    \"value\": 5377567\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5357\",\n",
       "                    \"value\": 4823191\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b89\\u5fbd\",\n",
       "                    \"value\": 4430924\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5317\",\n",
       "                    \"value\": 4348298\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d59\\u6c5f\",\n",
       "                    \"value\": 3829609\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5317\",\n",
       "                    \"value\": 3791526\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u897f\",\n",
       "                    \"value\": 3249324\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8fbd\\u5b81\",\n",
       "                    \"value\": 3224900\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e91\\u5357\",\n",
       "                    \"value\": 2700426\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u897f\",\n",
       "                    \"value\": 2564797\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u91cd\\u5e86\",\n",
       "                    \"value\": 2556992\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9655\\u897f\",\n",
       "                    \"value\": 2360804\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9ed1\\u9f99\\u6c5f\",\n",
       "                    \"value\": 2305384\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8d35\\u5dde\",\n",
       "                    \"value\": 2292084\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u798f\\u5efa\",\n",
       "                    \"value\": 2263365\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u897f\",\n",
       "                    \"value\": 2011676\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5409\\u6797\",\n",
       "                    \"value\": 1678527\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e0a\\u6d77\",\n",
       "                    \"value\": 1619298\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7518\\u8083\",\n",
       "                    \"value\": 1578166\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5185\\u8499\\u53e4\",\n",
       "                    \"value\": 1377709\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5317\\u4eac\",\n",
       "                    \"value\": 1207750\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65b0\\u7586\",\n",
       "                    \"value\": 1086542\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5929\\u6d25\",\n",
       "                    \"value\": 781761\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d77\\u5357\",\n",
       "                    \"value\": 524487\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b81\\u590f\",\n",
       "                    \"value\": 295500\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9752\\u6d77\",\n",
       "                    \"value\": 273812\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u897f\\u85cf\",\n",
       "                    \"value\": 123015\n",
       "                }\n",
       "            ],\n",
       "            \"roam\": true,\n",
       "            \"aspectScale\": 0.75,\n",
       "            \"nameProperty\": \"name\",\n",
       "            \"selectedMode\": false,\n",
       "            \"zoom\": 1,\n",
       "            \"mapValueCalculation\": \"sum\",\n",
       "            \"showLegendSymbol\": false,\n",
       "            \"emphasis\": {},\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5168\\u56fd\\u8001\\u5e74\\u4eba\\u53e3\\u5206\\u5e03\\u5730\\u56fe\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"continuous\",\n",
       "        \"min\": 123015,\n",
       "        \"max\": 6746757,\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"lightskyblue\",\n",
       "                \"yellow\",\n",
       "                \"orangered\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 140,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "                chart_1dcbe18b29814c8a9005d40d50bf3856.setOption(option_1dcbe18b29814c8a9005d40d50bf3856);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be556e400>"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x_data = renkou['地区'].tolist()\n",
    "y_data =renkou['合计'].tolist()\n",
    "\n",
    "m = Map()\n",
    "m.add('',[list(z) for z in zip(x_data,y_data)],maptype = 'china',is_map_symbol_show=False)\n",
    "m.set_series_opts(label_opts = opts.LabelOpts(is_show=True))\n",
    "m.set_global_opts(title_opts = opts.TitleOpts(title = '全国老年人口分布地图'),\n",
    "visualmap_opts = opts.VisualMapOpts(min_=renkou['合计'].min(),max_=renkou['合计'].max(),\n",
    "range_color=['lightskyblue','yellow','orangered']))\n",
    "m.render_notebook()\n",
    "# m.render('html/全国老年人口分布地图.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "eaa3fcc4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'china':'https://assets.pyecharts.org/assets/maps/china'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"203f1c8543634a4198eb80fe7741f07c\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'china'], function(echarts) {\n",
       "                var chart_203f1c8543634a4198eb80fe7741f07c = echarts.init(\n",
       "                    document.getElementById('203f1c8543634a4198eb80fe7741f07c'), 'white', {renderer: 'canvas'});\n",
       "                var option_203f1c8543634a4198eb80fe7741f07c = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"map\",\n",
       "            \"name\": \"\\u517b\\u8001\\u673a\\u6784\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"mapType\": \"china\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5357\\u7701\",\n",
       "                    \"value\": 3340\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b89\\u5fbd\\u7701\",\n",
       "                    \"value\": 2596\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u56db\\u5ddd\\u7701\",\n",
       "                    \"value\": 2504\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u82cf\\u7701\",\n",
       "                    \"value\": 2494\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5357\\u7701\",\n",
       "                    \"value\": 2417\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u4e1c\\u7701\",\n",
       "                    \"value\": 2271\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8fbd\\u5b81\\u7701\",\n",
       "                    \"value\": 2171\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9ed1\\u9f99\\u6c5f\\u7701\",\n",
       "                    \"value\": 2055\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5317\\u7701\",\n",
       "                    \"value\": 1968\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u4e1c\\u7701\",\n",
       "                    \"value\": 1958\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u897f\\u7701\",\n",
       "                    \"value\": 1854\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5317\\u7701\",\n",
       "                    \"value\": 1782\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d59\\u6c5f\\u7701\",\n",
       "                    \"value\": 1678\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5409\\u6797\\u7701\",\n",
       "                    \"value\": 1520\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u91cd\\u5e86\\u5e02\",\n",
       "                    \"value\": 1146\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8d35\\u5dde\\u7701\",\n",
       "                    \"value\": 968\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e91\\u5357\\u7701\",\n",
       "                    \"value\": 903\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u897f\\u7701\",\n",
       "                    \"value\": 774\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9655\\u897f\\u7701\",\n",
       "                    \"value\": 763\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u798f\\u5efa\\u7701\",\n",
       "                    \"value\": 762\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e0a\\u6d77\\u5e02\",\n",
       "                    \"value\": 681\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5185\\u8499\\u53e4\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 665\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u897f\\u58ee\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 588\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5317\\u4eac\\u5e02\",\n",
       "                    \"value\": 571\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5929\\u6d25\\u5e02\",\n",
       "                    \"value\": 407\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65b0\\u7586\\u7ef4\\u543e\\u5c14\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 396\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7518\\u8083\\u7701\",\n",
       "                    \"value\": 278\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b81\\u590f\\u56de\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 131\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9752\\u6d77\\u7701\",\n",
       "                    \"value\": 64\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d77\\u5357\\u7701\",\n",
       "                    \"value\": 59\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u897f\\u85cf\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 53\n",
       "                }\n",
       "            ],\n",
       "            \"roam\": true,\n",
       "            \"aspectScale\": 0.75,\n",
       "            \"nameProperty\": \"name\",\n",
       "            \"selectedMode\": false,\n",
       "            \"zoom\": 1,\n",
       "            \"mapValueCalculation\": \"sum\",\n",
       "            \"showLegendSymbol\": false,\n",
       "            \"emphasis\": {},\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u517b\\u8001\\u673a\\u6784\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u517b\\u8001\\u673a\\u6784\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5168\\u56fd\\u8001\\u5e74\\u4eba\\u53e3\\u5206\\u5e03\\u5730\\u56fe\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"continuous\",\n",
       "        \"min\": 53,\n",
       "        \"max\": 3340,\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"#C2E7C0\",\n",
       "                \"#61BDCD\",\n",
       "                \"#0D6DAE\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 140,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "                chart_203f1c8543634a4198eb80fe7741f07c.setOption(option_203f1c8543634a4198eb80fe7741f07c);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be55a97f0>"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x_data = jigou['省份'].tolist()\n",
    "y_data =jigou['养老机构(个)'].tolist()\n",
    "\n",
    "m = Map()\n",
    "m.add('养老机构',[list(z) for z in zip(x_data,y_data)],maptype = 'china',is_map_symbol_show=False)\n",
    "m.set_series_opts(label_opts = opts.LabelOpts(is_show=True))\n",
    "m.set_global_opts(title_opts = opts.TitleOpts(title = '全国老年人口分布地图'),\n",
    "visualmap_opts = opts.VisualMapOpts(min_=jigou['养老机构(个)'].min(),max_=jigou['养老机构(个)'].max(),\n",
    "range_color=['#C2E7C0','#61BDCD','#0D6DAE']))\n",
    "m.render_notebook()\n",
    "# m.render('html/全国老年人口分布地图.html')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "548517c2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[('河南省', 3340), ('安徽省', 2596), ('四川省', 2504), ('江苏省', 2494), ('湖南省', 2417), ('山东省', 2271), ('辽宁省', 2171), ('黑龙江省', 2055), ('湖北省', 1968), ('广东省', 1958), ('江西省', 1854), ('河北省', 1782), ('浙江省', 1678), ('吉林省', 1520), ('重庆市', 1146), ('贵州省', 968), ('云南省', 903), ('山西省', 774), ('陕西省', 763), ('福建省', 762), ('上海市', 681), ('内蒙古自治区', 665), ('广西壮族自治区', 588), ('北京市', 571), ('天津市', 407), ('新疆维吾尔自治区', 396), ('甘肃省', 278), ('宁夏回族自治区', 131), ('青海省', 64), ('海南省', 59), ('西藏自治区', 53)]\n",
      "\n",
      "[('河南省', 3340), ('安徽省', 2596), ('四川省', 2504), ('江苏省', 2494), ('湖南省', 2417), ('山东省', 2271), ('辽宁省', 2171), ('黑龙江省', 2055), ('湖北省', 1968), ('广东省', 1958), ('江西省', 1854), ('河北省', 1782), ('浙江省', 1678), ('吉林省', 1520), ('重庆市', 1146), ('贵州省', 968), ('云南省', 903), ('山西省', 774), ('陕西省', 763), ('福建省', 762), ('上海市', 681), ('内蒙古自治区', 665), ('广西壮族自治区', 588), ('北京市', 571), ('天津市', 407), ('新疆维吾尔自治区', 396), ('甘肃省', 278), ('宁夏回族自治区', 131), ('青海省', 64), ('海南省', 59), ('西藏自治区', 53)]\n",
      "\n",
      "[['河南省', 3340], ['安徽省', 2596], ['四川省', 2504], ['江苏省', 2494], ['湖南省', 2417], ['山东省', 2271], ['辽宁省', 2171], ['黑龙江省', 2055], ['湖北省', 1968], ['广东省', 1958], ['江西省', 1854], ['河北省', 1782], ['浙江省', 1678], ['吉林省', 1520], ['重庆市', 1146], ['贵州省', 968], ['云南省', 903], ['山西省', 774], ['陕西省', 763], ['福建省', 762], ['上海市', 681], ['内蒙古自治区', 665], ['广西壮族自治区', 588], ['北京市', 571], ['天津市', 407], ['新疆维吾尔自治区', 396], ['甘肃省', 278], ['宁夏回族自治区', 131], ['青海省', 64], ['海南省', 59], ['西藏自治区', 53]]\n",
      "\n",
      "[['河南省', 335165], ['安徽省', 377487], ['四川省', 297964], ['江苏省', 439914], ['湖南省', 261817], ['山东省', 380438], ['辽宁省', 183863], ['黑龙江省', 176705], ['湖北省', 283738], ['广东省', 247579], ['江西省', 176526], ['河北省', 238320], ['浙江省', 266521], ['吉林省', 141744], ['重庆市', 121983], ['贵州省', 84629], ['云南省', 92234], ['山西省', 85829], ['陕西省', 108086], ['福建省', 106798], ['上海市', 147671], ['内蒙古自治区', 78229], ['广西壮族自治区', 85500], ['北京市', 108640], ['天津市', 60149], ['新疆维吾尔自治区', 51477], ['甘肃省', 30421], ['宁夏回族自治区', 25224], ['青海省', 6440], ['海南省', 8695], ['西藏自治区', 6399]]\n"
     ]
    }
   ],
   "source": [
    "jigou = pd.read_csv('data/不同地区养老机构.csv',encoding=\"utf-8\")\n",
    "city=jigou.iloc[:,0]\n",
    "population=jigou.iloc[:,1]\n",
    "z1=[i for i in zip(city,population)]\n",
    "z2=list(zip(city,population))\n",
    "z3=[list(i) for i in zip(city,population)]\n",
    "z4=jigou[['省份','养老机构床位数(万张)']].values.tolist()\n",
    "print(z1,z2,z3,z4,sep='\\n\\n') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "188c136a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'china':'https://assets.pyecharts.org/assets/maps/china'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"764ef64a113b4782b405b7540a944107\" style=\"width:1200px; height:600px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'china'], function(echarts) {\n",
       "                var chart_764ef64a113b4782b405b7540a944107 = echarts.init(\n",
       "                    document.getElementById('764ef64a113b4782b405b7540a944107'), 'white', {renderer: 'canvas'});\n",
       "                var option_764ef64a113b4782b405b7540a944107 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"map\",\n",
       "            \"name\": \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5e02\\u517b\\u8001\\u4fdd\\u9669\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"mapType\": \"china\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5357\\u7701\",\n",
       "                    \"value\": 335165\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b89\\u5fbd\\u7701\",\n",
       "                    \"value\": 377487\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u56db\\u5ddd\\u7701\",\n",
       "                    \"value\": 297964\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u82cf\\u7701\",\n",
       "                    \"value\": 439914\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5357\\u7701\",\n",
       "                    \"value\": 261817\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u4e1c\\u7701\",\n",
       "                    \"value\": 380438\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8fbd\\u5b81\\u7701\",\n",
       "                    \"value\": 183863\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9ed1\\u9f99\\u6c5f\\u7701\",\n",
       "                    \"value\": 176705\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5317\\u7701\",\n",
       "                    \"value\": 283738\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u4e1c\\u7701\",\n",
       "                    \"value\": 247579\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u897f\\u7701\",\n",
       "                    \"value\": 176526\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5317\\u7701\",\n",
       "                    \"value\": 238320\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d59\\u6c5f\\u7701\",\n",
       "                    \"value\": 266521\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5409\\u6797\\u7701\",\n",
       "                    \"value\": 141744\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u91cd\\u5e86\\u5e02\",\n",
       "                    \"value\": 121983\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8d35\\u5dde\\u7701\",\n",
       "                    \"value\": 84629\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e91\\u5357\\u7701\",\n",
       "                    \"value\": 92234\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u897f\\u7701\",\n",
       "                    \"value\": 85829\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9655\\u897f\\u7701\",\n",
       "                    \"value\": 108086\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u798f\\u5efa\\u7701\",\n",
       "                    \"value\": 106798\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e0a\\u6d77\\u5e02\",\n",
       "                    \"value\": 147671\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5185\\u8499\\u53e4\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 78229\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u897f\\u58ee\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 85500\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5317\\u4eac\\u5e02\",\n",
       "                    \"value\": 108640\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5929\\u6d25\\u5e02\",\n",
       "                    \"value\": 60149\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65b0\\u7586\\u7ef4\\u543e\\u5c14\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 51477\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7518\\u8083\\u7701\",\n",
       "                    \"value\": 30421\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b81\\u590f\\u56de\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 25224\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9752\\u6d77\\u7701\",\n",
       "                    \"value\": 6440\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d77\\u5357\\u7701\",\n",
       "                    \"value\": 8695\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u897f\\u85cf\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 6399\n",
       "                }\n",
       "            ],\n",
       "            \"roam\": true,\n",
       "            \"aspectScale\": 0.75,\n",
       "            \"nameProperty\": \"name\",\n",
       "            \"selectedMode\": false,\n",
       "            \"zoom\": 1,\n",
       "            \"mapValueCalculation\": \"sum\",\n",
       "            \"showLegendSymbol\": false,\n",
       "            \"emphasis\": {},\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5e02\\u517b\\u8001\\u4fdd\\u9669\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5e02\\u517b\\u8001\\u4fdd\\u9669\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5e7f\\u4e1c\\u4eba\\u53e3\\u5206\\u5e03\\u56fe\",\n",
       "            \"subtext\": \"\\u6570\\u636e\\u6765\\u6e90\\uff1a\\u5e7f\\u4e1c\\u7edf\\u8ba1\\u5e74\\u9274\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"piecewise\",\n",
       "        \"min\": 0,\n",
       "        \"max\": 3340,\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"lightskyblue\",\n",
       "                \"yellow\",\n",
       "                \"orangered\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 14,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "                chart_764ef64a113b4782b405b7540a944107.setOption(option_764ef64a113b4782b405b7540a944107);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be569c040>"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "map=Map(init_opts=opts.InitOpts(width=\"1200px\",height='600px'))\n",
    "map.add('广东省各市养老保险',data_pair=z4,maptype='china',is_map_symbol_show=False)\n",
    "map.set_series_opts(label_opts=opts.LabelOpts(is_show=True))\n",
    "map.set_global_opts(title_opts=opts.TitleOpts(title='广东人口分布图',subtitle='数据来源：广东统计年鉴'),\n",
    "    visualmap_opts=opts.VisualMapOpts(max_=3340,is_piecewise=True,range_color=['lightskyblue','yellow','orangered']))\n",
    "# map.render('map地图.html')\n",
    "map.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "8c17facb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', 'china':'https://assets.pyecharts.org/assets/maps/china'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"16842b5865be406793706683794c3455\" style=\"width:1200px; height:600px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', 'china'], function(echarts) {\n",
       "                var chart_16842b5865be406793706683794c3455 = echarts.init(\n",
       "                    document.getElementById('16842b5865be406793706683794c3455'), 'white', {renderer: 'canvas'});\n",
       "                var option_16842b5865be406793706683794c3455 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"map\",\n",
       "            \"name\": \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5e02\\u517b\\u8001\\u4fdd\\u9669\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"mapType\": \"china\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5357\\u7701\",\n",
       "                    \"value\": 3340\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b89\\u5fbd\\u7701\",\n",
       "                    \"value\": 2596\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u56db\\u5ddd\\u7701\",\n",
       "                    \"value\": 2504\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u82cf\\u7701\",\n",
       "                    \"value\": 2494\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5357\\u7701\",\n",
       "                    \"value\": 2417\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u4e1c\\u7701\",\n",
       "                    \"value\": 2271\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8fbd\\u5b81\\u7701\",\n",
       "                    \"value\": 2171\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9ed1\\u9f99\\u6c5f\\u7701\",\n",
       "                    \"value\": 2055\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e56\\u5317\\u7701\",\n",
       "                    \"value\": 1968\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u4e1c\\u7701\",\n",
       "                    \"value\": 1958\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u897f\\u7701\",\n",
       "                    \"value\": 1854\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6cb3\\u5317\\u7701\",\n",
       "                    \"value\": 1782\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d59\\u6c5f\\u7701\",\n",
       "                    \"value\": 1678\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5409\\u6797\\u7701\",\n",
       "                    \"value\": 1520\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u91cd\\u5e86\\u5e02\",\n",
       "                    \"value\": 1146\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8d35\\u5dde\\u7701\",\n",
       "                    \"value\": 968\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e91\\u5357\\u7701\",\n",
       "                    \"value\": 903\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5c71\\u897f\\u7701\",\n",
       "                    \"value\": 774\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9655\\u897f\\u7701\",\n",
       "                    \"value\": 763\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u798f\\u5efa\\u7701\",\n",
       "                    \"value\": 762\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e0a\\u6d77\\u5e02\",\n",
       "                    \"value\": 681\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5185\\u8499\\u53e4\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 665\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u897f\\u58ee\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 588\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5317\\u4eac\\u5e02\",\n",
       "                    \"value\": 571\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5929\\u6d25\\u5e02\",\n",
       "                    \"value\": 407\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u65b0\\u7586\\u7ef4\\u543e\\u5c14\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 396\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u7518\\u8083\\u7701\",\n",
       "                    \"value\": 278\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5b81\\u590f\\u56de\\u65cf\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 131\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9752\\u6d77\\u7701\",\n",
       "                    \"value\": 64\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d77\\u5357\\u7701\",\n",
       "                    \"value\": 59\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u897f\\u85cf\\u81ea\\u6cbb\\u533a\",\n",
       "                    \"value\": 53\n",
       "                }\n",
       "            ],\n",
       "            \"roam\": true,\n",
       "            \"aspectScale\": 0.75,\n",
       "            \"nameProperty\": \"name\",\n",
       "            \"selectedMode\": false,\n",
       "            \"zoom\": 1,\n",
       "            \"mapValueCalculation\": \"sum\",\n",
       "            \"showLegendSymbol\": true,\n",
       "            \"emphasis\": {},\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5e02\\u517b\\u8001\\u4fdd\\u9669\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5e02\\u517b\\u8001\\u4fdd\\u9669\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5e7f\\u4e1c\\u4eba\\u53e3\\u5206\\u5e03\\u56fe\",\n",
       "            \"subtext\": \"\\u6570\\u636e\\u6765\\u6e90\\uff1a\\u5e7f\\u4e1c\\u7edf\\u8ba1\\u5e74\\u9274\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"piecewise\",\n",
       "        \"min\": 0,\n",
       "        \"max\": 3340,\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"lightskyblue\",\n",
       "                \"yellow\",\n",
       "                \"orangered\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 14,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "                chart_16842b5865be406793706683794c3455.setOption(option_16842b5865be406793706683794c3455);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be5583c40>"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "map=Map(init_opts=opts.InitOpts(width=\"1200px\",height='600px'))\n",
    "map.add('广东省各市养老保险',jigou[['省份','养老机构(个)']].values.tolist(),\"china\")\n",
    "map.set_series_opts(label_opts=opts.LabelOpts(is_show=True))\n",
    "map.set_global_opts(title_opts=opts.TitleOpts(title='广东人口分布图',subtitle='数据来源：广东统计年鉴'),\n",
    "    visualmap_opts=opts.VisualMapOpts(max_=3340,is_piecewise=True,range_color=['lightskyblue','yellow','orangered']))\n",
    "# map.render('map地图.html')\n",
    "map.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0d0bfe0c",
   "metadata": {},
   "source": [
    "## 不同年份养老机构数量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 138,
   "id": "75623fcc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>年份</th>\n",
       "      <th>养老服务机构和设施总数(万个)</th>\n",
       "      <th>养老服务机构(万个)</th>\n",
       "      <th>社区养老服务机构和设施(万个)</th>\n",
       "      <th>互助型的养老设施(万个)</th>\n",
       "      <th>养老机构入住率(%)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2010</td>\n",
       "      <td>4.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2011</td>\n",
       "      <td>4.1</td>\n",
       "      <td>4.1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2012</td>\n",
       "      <td>4.4</td>\n",
       "      <td>4.4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2013</td>\n",
       "      <td>4.3</td>\n",
       "      <td>4.3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2014</td>\n",
       "      <td>9.4</td>\n",
       "      <td>3.3</td>\n",
       "      <td>1.9</td>\n",
       "      <td>4.0</td>\n",
       "      <td>62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2015</td>\n",
       "      <td>11.6</td>\n",
       "      <td>2.8</td>\n",
       "      <td>2.6</td>\n",
       "      <td>6.2</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2016</td>\n",
       "      <td>14.0</td>\n",
       "      <td>2.9</td>\n",
       "      <td>3.5</td>\n",
       "      <td>7.6</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2017</td>\n",
       "      <td>15.5</td>\n",
       "      <td>2.9</td>\n",
       "      <td>4.3</td>\n",
       "      <td>8.3</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     年份  养老服务机构和设施总数(万个)  养老服务机构(万个)  社区养老服务机构和设施(万个)  互助型的养老设施(万个)  \\\n",
       "0  2010              4.0         4.0              NaN           NaN   \n",
       "1  2011              4.1         4.1              NaN           NaN   \n",
       "2  2012              4.4         4.4              NaN           NaN   \n",
       "3  2013              4.3         4.3              NaN           NaN   \n",
       "4  2014              9.4         3.3              1.9           4.0   \n",
       "5  2015             11.6         2.8              2.6           6.2   \n",
       "6  2016             14.0         2.9              3.5           7.6   \n",
       "7  2017             15.5         2.9              4.3           8.3   \n",
       "\n",
       "   养老机构入住率(%)  \n",
       "0          79  \n",
       "1          77  \n",
       "2          74  \n",
       "3          70  \n",
       "4          62  \n",
       "5          55  \n",
       "6          52  \n",
       "7          48  "
      ]
     },
     "execution_count": 138,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nianfen=pd.read_excel('data/不同年份养老机构数量.xlsx',\n",
    "                        sheet_name='数据'\n",
    "                     )\n",
    "nianfen"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7d7c7a85",
   "metadata": {},
   "source": [
    "### 柱状图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 144,
   "id": "a1819c9f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"3f9c91c4a0124ed5939b0a0ae0e1a0a9\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_3f9c91c4a0124ed5939b0a0ae0e1a0a9 = echarts.init(\n",
       "                    document.getElementById('3f9c91c4a0124ed5939b0a0ae0e1a0a9'), 'white', {renderer: 'canvas'});\n",
       "                var option_3f9c91c4a0124ed5939b0a0ae0e1a0a9 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                4.0,\n",
       "                4.1,\n",
       "                4.4,\n",
       "                4.3,\n",
       "                9.4,\n",
       "                11.6,\n",
       "                14.0,\n",
       "                15.5\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                2010,\n",
       "                2011,\n",
       "                2012,\n",
       "                2013,\n",
       "                2014,\n",
       "                2015,\n",
       "                2016,\n",
       "                2017\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false,\n",
       "        \"filterMode\": \"filter\"\n",
       "    }\n",
       "};\n",
       "                chart_3f9c91c4a0124ed5939b0a0ae0e1a0a9.setOption(option_3f9c91c4a0124ed5939b0a0ae0e1a0a9);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be556f0a0>"
      ]
     },
     "execution_count": 144,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts.charts import Bar\n",
    "#xy轴数据\n",
    "x= nianfen[\"年份\"]\n",
    "x1=list(x)\n",
    "\n",
    "y=nianfen[\"养老服务机构和设施总数(万个)\"]\n",
    "y1=list(y)\n",
    "\n",
    "#柱形图\n",
    "l1=x1\n",
    "l2=y1\n",
    "bar = (\n",
    "    Bar()\n",
    "    .add_xaxis(l1)\n",
    "    .add_yaxis(\"不同年份养老机构数量\", l2)\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"不同年份养老机构数量\"),\n",
    "                     datazoom_opts=opts.DataZoomOpts(type_=\"slider\"))\n",
    ")\n",
    "bar.render_notebook()\n",
    "# bar.render('html/不同养老机构服务价格.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dda58172",
   "metadata": {},
   "source": [
    "### 折线图（无标签）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "62d92711",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017]"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x= nianfen[\"年份\"]\n",
    "x1=list(x)\n",
    "x1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "id": "bd3caceb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[4.0, 4.1, 4.4, 4.3, 9.4, 11.6, 14.0, 15.5]"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y=nianfen[\"养老服务机构和设施总数(万个)\"]\n",
    "y1=list(y)\n",
    "y1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 145,
   "id": "ce769509",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"af943c943f6d4c16b25343677609d582\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_af943c943f6d4c16b25343677609d582 = echarts.init(\n",
       "                    document.getElementById('af943c943f6d4c16b25343677609d582'), 'white', {renderer: 'canvas'});\n",
       "                var option_af943c943f6d4c16b25343677609d582 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u57fa\\u672c\\u6298\\u7ebf\\u56fe\",\n",
       "            \"connectNulls\": false,\n",
       "            \"symbol\": \"emptyCircle\",\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2010\",\n",
       "                    4.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2011\",\n",
       "                    4.1\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u661f\\u671f\\u4e09\",\n",
       "                    4.4\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u661f\\u671f\\u56db\",\n",
       "                    4.3\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u661f\\u671f\\u4e94\",\n",
       "                    9.4\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u661f\\u671f\\u4e03\",\n",
       "                    11.6\n",
       "                ],\n",
       "                [\n",
       "                    \"\\u661f\\u671f\\u65e5\",\n",
       "                    14.0\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u57fa\\u672c\\u6298\\u7ebf\\u56fe\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u57fa\\u672c\\u6298\\u7ebf\\u56fe\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": false,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"type\": \"category\",\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2010\",\n",
       "                \"2011\",\n",
       "                \"\\u661f\\u671f\\u4e09\",\n",
       "                \"\\u661f\\u671f\\u56db\",\n",
       "                \"\\u661f\\u671f\\u4e94\",\n",
       "                \"\\u661f\\u671f\\u4e03\",\n",
       "                \"\\u661f\\u671f\\u65e5\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"type\": \"value\",\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"axisTick\": {\n",
       "                \"show\": true,\n",
       "                \"alignWithLabel\": false,\n",
       "                \"inside\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_af943c943f6d4c16b25343677609d582.setOption(option_af943c943f6d4c16b25343677609d582);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be6077be0>"
      ]
     },
     "execution_count": 145,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Line\n",
    "x=['2010','2011','星期三','星期四','星期五','星期七','星期日']\n",
    "y=y1\n",
    "\n",
    "line=(\n",
    "    Line()\n",
    "    .set_global_opts(\n",
    "        tooltip_opts=opts.TooltipOpts(is_show=False),\n",
    "        xaxis_opts=opts.AxisOpts(type_=\"category\"),\n",
    "        yaxis_opts=opts.AxisOpts(\n",
    "            type_=\"value\",\n",
    "            axistick_opts=opts.AxisTickOpts(is_show=True),\n",
    "            splitline_opts=opts.SplitLineOpts(is_show=True),\n",
    "        ),\n",
    "    )\n",
    "    .add_xaxis(xaxis_data=x)\n",
    "    .add_yaxis(\n",
    "        series_name=\"基本折线图\",\n",
    "        y_axis=y,\n",
    "        symbol=\"emptyCircle\",\n",
    "        is_symbol_show=True,\n",
    "        label_opts=opts.LabelOpts(is_show=False),\n",
    "    )\n",
    ")\n",
    "line.render_notebook()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4218dffb",
   "metadata": {},
   "source": [
    "### 折线图（有标签）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 150,
   "id": "265ffd17",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"8612d8165c8f4e79aead5b2ef194cd01\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_8612d8165c8f4e79aead5b2ef194cd01 = echarts.init(\n",
       "                    document.getElementById('8612d8165c8f4e79aead5b2ef194cd01'), 'white', {renderer: 'canvas'});\n",
       "                var option_8612d8165c8f4e79aead5b2ef194cd01 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\",\n",
       "            \"connectNulls\": true,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2010\",\n",
       "                    4.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2011\",\n",
       "                    4.1\n",
       "                ],\n",
       "                [\n",
       "                    \"2012\",\n",
       "                    4.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2013\",\n",
       "                    4.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2014\",\n",
       "                    9.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2015\",\n",
       "                    11.6\n",
       "                ],\n",
       "                [\n",
       "                    \"2016\",\n",
       "                    14.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2017\",\n",
       "                    15.5\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2010\",\n",
       "                \"2011\",\n",
       "                \"2012\",\n",
       "                \"2013\",\n",
       "                \"2014\",\n",
       "                \"2015\",\n",
       "                \"2016\",\n",
       "                \"2017\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"Line-\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_8612d8165c8f4e79aead5b2ef194cd01.setOption(option_8612d8165c8f4e79aead5b2ef194cd01);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be5df9af0>"
      ]
     },
     "execution_count": 150,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Line\n",
    "\n",
    "\n",
    "x=['2010','2011','2012','2013','2014','2015','2016','2017']\n",
    "y=y1\n",
    "\n",
    "line=(\n",
    "    Line()\n",
    "    .add_xaxis(xaxis_data=x)\n",
    "    .add_yaxis(\n",
    "        series_name=\"连接空数据（折线图）\",\n",
    "        y_axis=y,\n",
    "        is_connect_nones=True\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"Line-连接空数据\"))\n",
    ")\n",
    "line.render_notebook()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e147fb44",
   "metadata": {},
   "source": [
    "### 折线图与柱状图合体"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "id": "8fcc3db4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<pyecharts.charts.basic_charts.bar.Bar at 0x26be5e0ad60>"
      ]
     },
     "execution_count": 126,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "all=bar.overlap(line)\n",
    "all"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "id": "18d8ab41",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "from  pyecharts import options as  opts\n",
    "\n",
    "\n",
    "from pyecharts.charts import Pie\n",
    "\n",
    "\n",
    "from pyecharts.globals import ThemeType\n",
    "\n",
    "\n",
    "from  pyecharts.charts import Bar\n",
    "\n",
    "from  pyecharts.charts import  Line\n",
    "\n",
    "from  pyecharts.charts import  *\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "id": "c32c95e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<pyecharts.charts.composite_charts.grid.Grid at 0x26be5e2f460>"
      ]
     },
     "execution_count": 130,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "aa=Grid(\n",
    "    #画布配置\n",
    "    init_opts=opts.InitOpts(\n",
    "        width=\"1500px\",  #图的大小\n",
    "        height='650px',\n",
    "\n",
    "))\n",
    "aa.add(all,\n",
    "       #网格配置\n",
    "       grid_opts=opts.GridOpts(\n",
    "           pos_top=\"20%\",\n",
    "           pos_left=\"5%\",\n",
    "           pos_right=\"40%\",\n",
    "       ),\n",
    "       # 索引\n",
    "       is_control_axis_index=True #控制索引\n",
    "       )\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 149,
   "id": "eb1ec3a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"0b54ab119a36442183f17307e8d07b91\" style=\"width:1500px; height:650px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_0b54ab119a36442183f17307e8d07b91 = echarts.init(\n",
       "                    document.getElementById('0b54ab119a36442183f17307e8d07b91'), 'white', {renderer: 'canvas'});\n",
       "                var option_0b54ab119a36442183f17307e8d07b91 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                4.0,\n",
       "                4.1,\n",
       "                4.4,\n",
       "                4.3,\n",
       "                9.4,\n",
       "                11.6,\n",
       "                14.0,\n",
       "                15.5\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\",\n",
       "            \"connectNulls\": true,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2010\",\n",
       "                    4.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2011\",\n",
       "                    4.1\n",
       "                ],\n",
       "                [\n",
       "                    \"2012\",\n",
       "                    4.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2013\",\n",
       "                    4.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2014\",\n",
       "                    9.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2015\",\n",
       "                    11.6\n",
       "                ],\n",
       "                [\n",
       "                    \"2016\",\n",
       "                    14.0\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\",\n",
       "            \"connectNulls\": true,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2010\",\n",
       "                    4.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2011\",\n",
       "                    4.1\n",
       "                ],\n",
       "                [\n",
       "                    \"2012\",\n",
       "                    4.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2013\",\n",
       "                    4.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2014\",\n",
       "                    9.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2015\",\n",
       "                    11.6\n",
       "                ],\n",
       "                [\n",
       "                    \"2016\",\n",
       "                    14.0\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\",\n",
       "            \"connectNulls\": true,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2010\",\n",
       "                    4.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2011\",\n",
       "                    4.1\n",
       "                ],\n",
       "                [\n",
       "                    \"2012\",\n",
       "                    4.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2013\",\n",
       "                    4.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2014\",\n",
       "                    9.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2015\",\n",
       "                    11.6\n",
       "                ],\n",
       "                [\n",
       "                    \"2016\",\n",
       "                    14.0\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\",\n",
       "            \"connectNulls\": true,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2010\",\n",
       "                    4.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2011\",\n",
       "                    4.1\n",
       "                ],\n",
       "                [\n",
       "                    \"2012\",\n",
       "                    4.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2013\",\n",
       "                    4.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2014\",\n",
       "                    9.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2015\",\n",
       "                    11.6\n",
       "                ],\n",
       "                [\n",
       "                    \"2016\",\n",
       "                    14.0\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\",\n",
       "                \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\",\n",
       "                \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\",\n",
       "                \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\",\n",
       "                \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\": true,\n",
       "                \"\\u8fde\\u63a5\\u7a7a\\u6570\\u636e\\uff08\\u6298\\u7ebf\\u56fe\\uff09\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                2010,\n",
       "                2011,\n",
       "                2012,\n",
       "                2013,\n",
       "                2014,\n",
       "                2015,\n",
       "                2016,\n",
       "                2017\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e0d\\u540c\\u5e74\\u4efd\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false,\n",
       "        \"filterMode\": \"filter\"\n",
       "    },\n",
       "    \"grid\": [\n",
       "        {\n",
       "            \"show\": false,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"left\": \"5%\",\n",
       "            \"top\": \"20%\",\n",
       "            \"right\": \"40%\",\n",
       "            \"containLabel\": false,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderWidth\": 1\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_0b54ab119a36442183f17307e8d07b91.setOption(option_0b54ab119a36442183f17307e8d07b91);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be5555e20>"
      ]
     },
     "execution_count": 149,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "aa.render('./疫情数据.html')\n",
    "aa.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fef561b4",
   "metadata": {},
   "source": [
    "## 养老机构数量与入住率"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "id": "3be4e99f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>年份</th>\n",
       "      <th>养老服务机构和设施总数(万个)</th>\n",
       "      <th>养老服务机构(万个)</th>\n",
       "      <th>社区养老服务机构和设施(万个)</th>\n",
       "      <th>互助型的养老设施(万个)</th>\n",
       "      <th>养老机构入住率(%)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2010</td>\n",
       "      <td>4.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>79</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2011</td>\n",
       "      <td>4.1</td>\n",
       "      <td>4.1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2012</td>\n",
       "      <td>4.4</td>\n",
       "      <td>4.4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2013</td>\n",
       "      <td>4.3</td>\n",
       "      <td>4.3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2014</td>\n",
       "      <td>9.4</td>\n",
       "      <td>3.3</td>\n",
       "      <td>1.9</td>\n",
       "      <td>4.0</td>\n",
       "      <td>62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2015</td>\n",
       "      <td>11.6</td>\n",
       "      <td>2.8</td>\n",
       "      <td>2.6</td>\n",
       "      <td>6.2</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2016</td>\n",
       "      <td>14.0</td>\n",
       "      <td>2.9</td>\n",
       "      <td>3.5</td>\n",
       "      <td>7.6</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2017</td>\n",
       "      <td>15.5</td>\n",
       "      <td>2.9</td>\n",
       "      <td>4.3</td>\n",
       "      <td>8.3</td>\n",
       "      <td>48</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     年份  养老服务机构和设施总数(万个)  养老服务机构(万个)  社区养老服务机构和设施(万个)  互助型的养老设施(万个)  \\\n",
       "0  2010              4.0         4.0              NaN           NaN   \n",
       "1  2011              4.1         4.1              NaN           NaN   \n",
       "2  2012              4.4         4.4              NaN           NaN   \n",
       "3  2013              4.3         4.3              NaN           NaN   \n",
       "4  2014              9.4         3.3              1.9           4.0   \n",
       "5  2015             11.6         2.8              2.6           6.2   \n",
       "6  2016             14.0         2.9              3.5           7.6   \n",
       "7  2017             15.5         2.9              4.3           8.3   \n",
       "\n",
       "   养老机构入住率(%)  \n",
       "0          79  \n",
       "1          77  \n",
       "2          74  \n",
       "3          70  \n",
       "4          62  \n",
       "5          55  \n",
       "6          52  \n",
       "7          48  "
      ]
     },
     "execution_count": 152,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nianfen=pd.read_excel('data/不同年份养老机构数量.xlsx', sheet_name='数据')\n",
    "nianfen"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8f04e80e",
   "metadata": {},
   "source": [
    "### 折线图(√）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "id": "2844da89",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"36504d2d34414ce085f6ec80a537d434\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_36504d2d34414ce085f6ec80a537d434 = echarts.init(\n",
       "                    document.getElementById('36504d2d34414ce085f6ec80a537d434'), 'white', {renderer: 'canvas'});\n",
       "                var option_36504d2d34414ce085f6ec80a537d434 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\\uff08\\u4e07\\u4e2a\\uff09\",\n",
       "            \"connectNulls\": false,\n",
       "            \"symbol\": \"arrow\",\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2010\",\n",
       "                    4.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2011\",\n",
       "                    4.1\n",
       "                ],\n",
       "                [\n",
       "                    \"2012\",\n",
       "                    4.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2013\",\n",
       "                    4.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2014\",\n",
       "                    9.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2015\",\n",
       "                    11.6\n",
       "                ],\n",
       "                [\n",
       "                    \"2016\",\n",
       "                    14.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2017\",\n",
       "                    15.5\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u517b\\u8001\\u673a\\u6784\\u5165\\u4f4f\\u7387(%)\",\n",
       "            \"connectNulls\": false,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": false,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2010\",\n",
       "                    79\n",
       "                ],\n",
       "                [\n",
       "                    \"2011\",\n",
       "                    77\n",
       "                ],\n",
       "                [\n",
       "                    \"2012\",\n",
       "                    74\n",
       "                ],\n",
       "                [\n",
       "                    \"2013\",\n",
       "                    70\n",
       "                ],\n",
       "                [\n",
       "                    \"2014\",\n",
       "                    62\n",
       "                ],\n",
       "                [\n",
       "                    \"2015\",\n",
       "                    55\n",
       "                ],\n",
       "                [\n",
       "                    \"2016\",\n",
       "                    52\n",
       "                ],\n",
       "                [\n",
       "                    \"2017\",\n",
       "                    48\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\\uff08\\u4e07\\u4e2a\\uff09\",\n",
       "                \"\\u517b\\u8001\\u673a\\u6784\\u5165\\u4f4f\\u7387(%)\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\\uff08\\u4e07\\u4e2a\\uff09\": true,\n",
       "                \"\\u517b\\u8001\\u673a\\u6784\\u5165\\u4f4f\\u7387(%)\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2010\",\n",
       "                \"2011\",\n",
       "                \"2012\",\n",
       "                \"2013\",\n",
       "                \"2014\",\n",
       "                \"2015\",\n",
       "                \"2016\",\n",
       "                \"2017\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u517b\\u8001\\u673a\\u6784\\u6570\\u91cf\\u4e0e\\u5165\\u4f4f\\u7387\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_36504d2d34414ce085f6ec80a537d434.setOption(option_36504d2d34414ce085f6ec80a537d434);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be60570a0>"
      ]
     },
     "execution_count": 155,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Line\n",
    "x=['2010','2011','2012','2013','2014','2015','2016','2017']\n",
    "\n",
    "y1_data=nianfen[\"养老服务机构和设施总数(万个)\"]\n",
    "y1=list(y1_data)\n",
    "\n",
    "y2_data=nianfen[\"养老机构入住率(%)\"]\n",
    "y2=list(y2_data)\n",
    "\n",
    "line=(\n",
    "    Line()\n",
    "    .add_xaxis(xaxis_data=x)\n",
    "    .add_yaxis(series_name=\"养老机构数量（万个）\",y_axis=y1,symbol=\"arrow\",is_symbol_show=True)\n",
    "    .add_yaxis(series_name=\"养老机构入住率(%)\",y_axis=y2)\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"养老机构数量与入住率\"))\n",
    ")\n",
    "line.render_notebook()\n",
    "# line.render('html/养老机构数量与入住率.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c564a693",
   "metadata": {},
   "source": [
    "# 养老保险"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ba9c8bb2",
   "metadata": {},
   "source": [
    "## 不同年份养老参保人数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "64be4a8c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>时间</th>\n",
       "      <th>养老参保人数(万人)</th>\n",
       "      <th>基金收入(亿元)</th>\n",
       "      <th>基金支出(亿元)</th>\n",
       "      <th>Unnamed: 4</th>\n",
       "      <th>Unnamed: 5</th>\n",
       "      <th>Unnamed: 6</th>\n",
       "      <th>Unnamed: 7</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2019</td>\n",
       "      <td>53266</td>\n",
       "      <td>4020.2</td>\n",
       "      <td>3113.9</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2018</td>\n",
       "      <td>52392</td>\n",
       "      <td>3808.6</td>\n",
       "      <td>2919.5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2017</td>\n",
       "      <td>51255</td>\n",
       "      <td>3288.0</td>\n",
       "      <td>2398.7</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2016</td>\n",
       "      <td>50847</td>\n",
       "      <td>3038.6</td>\n",
       "      <td>2291.9</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2015</td>\n",
       "      <td>50472</td>\n",
       "      <td>2951.8</td>\n",
       "      <td>2230.4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2014</td>\n",
       "      <td>50107</td>\n",
       "      <td>2386.9</td>\n",
       "      <td>1656.7</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2013</td>\n",
       "      <td>49750</td>\n",
       "      <td>2154.0</td>\n",
       "      <td>1453.7</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     时间  养老参保人数(万人)  基金收入(亿元)  基金支出(亿元)  Unnamed: 4  Unnamed: 5  Unnamed: 6  \\\n",
       "0  2019       53266    4020.2    3113.9         NaN         NaN         NaN   \n",
       "1  2018       52392    3808.6    2919.5         NaN         NaN         NaN   \n",
       "2  2017       51255    3288.0    2398.7         NaN         NaN         NaN   \n",
       "3  2016       50847    3038.6    2291.9         NaN         NaN         NaN   \n",
       "4  2015       50472    2951.8    2230.4         NaN         NaN         NaN   \n",
       "5  2014       50107    2386.9    1656.7         NaN         NaN         NaN   \n",
       "6  2013       49750    2154.0    1453.7         NaN         NaN         NaN   \n",
       "\n",
       "   Unnamed: 7  \n",
       "0         NaN  \n",
       "1         NaN  \n",
       "2         NaN  \n",
       "3         NaN  \n",
       "4         NaN  \n",
       "5         NaN  \n",
       "6         NaN  "
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "canbao = pd.read_csv('data/中国城乡居民基本养老保险.csv',encoding=\"gbk\")\n",
    "canbao"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b58ee9a5",
   "metadata": {},
   "source": [
    "### 柱形图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "143b7641",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"fd022b62dbff4557ae9274a11c4b7f02\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_fd022b62dbff4557ae9274a11c4b7f02 = echarts.init(\n",
       "                    document.getElementById('fd022b62dbff4557ae9274a11c4b7f02'), 'white', {renderer: 'canvas'});\n",
       "                var option_fd022b62dbff4557ae9274a11c4b7f02 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u8001\\u5e74\\u4eba\\u53e3\\u5730\\u533a\\u5206\\u5e03\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                53266,\n",
       "                52392,\n",
       "                51255,\n",
       "                50847,\n",
       "                50472,\n",
       "                50107,\n",
       "                49750\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u8001\\u5e74\\u4eba\\u53e3\\u5730\\u533a\\u5206\\u5e03\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u8001\\u5e74\\u4eba\\u53e3\\u5730\\u533a\\u5206\\u5e03\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                2019,\n",
       "                2018,\n",
       "                2017,\n",
       "                2016,\n",
       "                2015,\n",
       "                2014,\n",
       "                2013\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e0d\\u540c\\u4ef7\\u683c\\u6bb5\\u517b\\u8001\\u5206\\u5e03\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false,\n",
       "        \"filterMode\": \"filter\"\n",
       "    }\n",
       "};\n",
       "                chart_fd022b62dbff4557ae9274a11c4b7f02.setOption(option_fd022b62dbff4557ae9274a11c4b7f02);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be55a9640>"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts.charts import Bar\n",
    "#xy轴数据\n",
    "x=canbao['时间']\n",
    "x1=list(x)\n",
    "\n",
    "y=canbao['养老参保人数(万人)']\n",
    "y1=list(y)\n",
    "\n",
    "#柱形图\n",
    "l1=x1\n",
    "l2=y1\n",
    "bar = (\n",
    "    Bar()\n",
    "    .add_xaxis(l1)\n",
    "    .add_yaxis(\"老年人口地区分布\", l2)\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"不同价格段养老分布\"),\n",
    "                     datazoom_opts=opts.DataZoomOpts(type_=\"slider\"))\n",
    ")\n",
    "bar.render_notebook()\n",
    "# bar.render('不同行业公司数量图.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9e7d44c2",
   "metadata": {},
   "source": [
    "### 折线图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "dadf2bce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>指标</th>\n",
       "      <th>城乡居民社会养老保险参保人数(万人)</th>\n",
       "      <th>城乡居民社会养老保险实际领取待遇人数(万人)</th>\n",
       "      <th>城乡居民社会养老保险基金收入(亿元)</th>\n",
       "      <th>城乡居民社会养老保险基金支出(亿元)</th>\n",
       "      <th>城乡居民社会养老保险累计结余(亿元)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2012年</td>\n",
       "      <td>48369.5</td>\n",
       "      <td>13382.2</td>\n",
       "      <td>1829.2</td>\n",
       "      <td>1149.7</td>\n",
       "      <td>2302.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2013年</td>\n",
       "      <td>49750.1</td>\n",
       "      <td>14122.3</td>\n",
       "      <td>2052.3</td>\n",
       "      <td>1348.3</td>\n",
       "      <td>3005.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2014年</td>\n",
       "      <td>50107.5</td>\n",
       "      <td>14312.7</td>\n",
       "      <td>2310.2</td>\n",
       "      <td>1571.2</td>\n",
       "      <td>3844.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2015年</td>\n",
       "      <td>50472.2</td>\n",
       "      <td>14800.3</td>\n",
       "      <td>2854.6</td>\n",
       "      <td>2116.7</td>\n",
       "      <td>4592.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2016年</td>\n",
       "      <td>50847.1</td>\n",
       "      <td>15270.3</td>\n",
       "      <td>2933.3</td>\n",
       "      <td>2150.5</td>\n",
       "      <td>5385.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2017年</td>\n",
       "      <td>51255.0</td>\n",
       "      <td>15597.9</td>\n",
       "      <td>3304.2</td>\n",
       "      <td>2372.2</td>\n",
       "      <td>6317.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2018年</td>\n",
       "      <td>52391.7</td>\n",
       "      <td>15898.1</td>\n",
       "      <td>3837.7</td>\n",
       "      <td>2905.5</td>\n",
       "      <td>7250.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2019年</td>\n",
       "      <td>53266.0</td>\n",
       "      <td>16031.9</td>\n",
       "      <td>4107.0</td>\n",
       "      <td>3114.3</td>\n",
       "      <td>8249.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2020年</td>\n",
       "      <td>54243.8</td>\n",
       "      <td>16068.2</td>\n",
       "      <td>4852.9</td>\n",
       "      <td>3355.1</td>\n",
       "      <td>9758.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2021年</td>\n",
       "      <td>54797.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      指标  城乡居民社会养老保险参保人数(万人)  城乡居民社会养老保险实际领取待遇人数(万人)  城乡居民社会养老保险基金收入(亿元)  \\\n",
       "0  2012年             48369.5                 13382.2              1829.2   \n",
       "1  2013年             49750.1                 14122.3              2052.3   \n",
       "2  2014年             50107.5                 14312.7              2310.2   \n",
       "3  2015年             50472.2                 14800.3              2854.6   \n",
       "4  2016年             50847.1                 15270.3              2933.3   \n",
       "5  2017年             51255.0                 15597.9              3304.2   \n",
       "6  2018年             52391.7                 15898.1              3837.7   \n",
       "7  2019年             53266.0                 16031.9              4107.0   \n",
       "8  2020年             54243.8                 16068.2              4852.9   \n",
       "9  2021年             54797.0                     NaN                 NaN   \n",
       "\n",
       "   城乡居民社会养老保险基金支出(亿元)  城乡居民社会养老保险累计结余(亿元)  \n",
       "0              1149.7              2302.2  \n",
       "1              1348.3              3005.7  \n",
       "2              1571.2              3844.6  \n",
       "3              2116.7              4592.3  \n",
       "4              2150.5              5385.2  \n",
       "5              2372.2              6317.6  \n",
       "6              2905.5              7250.3  \n",
       "7              3114.3              8249.2  \n",
       "8              3355.1              9758.6  \n",
       "9                 NaN                 NaN  "
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "shebao= pd.read_csv('data/社会养老保险情况.csv',encoding=\"utf-8\")\n",
    "shebao"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "025ae3b6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"bf240d4a52d5477e901ec7d038c612e9\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_bf240d4a52d5477e901ec7d038c612e9 = echarts.init(\n",
       "                    document.getElementById('bf240d4a52d5477e901ec7d038c612e9'), 'white', {renderer: 'canvas'});\n",
       "                var option_bf240d4a52d5477e901ec7d038c612e9 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u4eba\\u6570\\u7ebf\",\n",
       "            \"connectNulls\": false,\n",
       "            \"symbolSize\": 4,\n",
       "            \"showSymbol\": true,\n",
       "            \"smooth\": true,\n",
       "            \"clip\": true,\n",
       "            \"step\": false,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2012\\u5e74\",\n",
       "                    48369.5\n",
       "                ],\n",
       "                [\n",
       "                    \"2013\\u5e74\",\n",
       "                    49750.1\n",
       "                ],\n",
       "                [\n",
       "                    \"2014\\u5e74\",\n",
       "                    50107.5\n",
       "                ],\n",
       "                [\n",
       "                    \"2015\\u5e74\",\n",
       "                    50472.2\n",
       "                ],\n",
       "                [\n",
       "                    \"2016\\u5e74\",\n",
       "                    50847.1\n",
       "                ],\n",
       "                [\n",
       "                    \"2017\\u5e74\",\n",
       "                    51255.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2018\\u5e74\",\n",
       "                    52391.7\n",
       "                ],\n",
       "                [\n",
       "                    \"2019\\u5e74\",\n",
       "                    53266.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2020\\u5e74\",\n",
       "                    54243.8\n",
       "                ],\n",
       "                [\n",
       "                    \"2021\\u5e74\",\n",
       "                    54797.0\n",
       "                ]\n",
       "            ],\n",
       "            \"hoverAnimation\": true,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"show\": true,\n",
       "                \"width\": 1,\n",
       "                \"opacity\": 1,\n",
       "                \"curveness\": 0,\n",
       "                \"type\": \"solid\"\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 0,\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4eba\\u6570\\u7ebf\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4eba\\u6570\\u7ebf\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"left\": \"90%\",\n",
       "            \"top\": \"35%\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2012\\u5e74\",\n",
       "                \"2013\\u5e74\",\n",
       "                \"2014\\u5e74\",\n",
       "                \"2015\\u5e74\",\n",
       "                \"2016\\u5e74\",\n",
       "                \"2017\\u5e74\",\n",
       "                \"2018\\u5e74\",\n",
       "                \"2019\\u5e74\",\n",
       "                \"2020\\u5e74\",\n",
       "                \"2021\\u5e74\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e2d\\u56fd\\u517b\\u8001\\u793e\\u4fdd\\u4eba\\u6570\\u6298\\u7ebf\\u56fe\",\n",
       "            \"subtext\": \"\\u6570\\u636e\\u8868\\u660e\\uff0c2010\\u81f32020\\u5e74\\u5e7f\\u4e1c\\u4eba\\u53e3\\u589e\\u957f\\u4e862\\u5343\\u591a\\u4e07\\uff0c\\u9ed1\\u9f99\\u6c5f\\u4eba\\u53e3\\u8d1f\\u589e\\u957f500\\u591a\\u4e07\\u3002\\n\\u8fdb\\u4e00\\u6b65\\u8bf4\\u660e\\u4e86\\u4eba\\u53e3\\u5411\\u7ecf\\u6d4e\\u53d1\\u8fbe\\u533a\\u57df\\u3001\\u57ce\\u5e02\\u7fa4\\u8fdb\\u4e00\\u6b65\\u96c6\\u805a\\u3002\",\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"0\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 25\n",
       "            }\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_bf240d4a52d5477e901ec7d038c612e9.setOption(option_bf240d4a52d5477e901ec7d038c612e9);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be568f0a0>"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "line=(\n",
    "    Line(init_opts=opts.InitOpts(width=\"900px\", height=\"500px\"))\n",
    "    .add_xaxis(xaxis_data=shebao['指标'].tolist())\n",
    "    .add_yaxis(series_name=\"人数线\",y_axis=shebao['城乡居民社会养老保险参保人数(万人)'].tolist(), is_smooth=True)\n",
    "#     .add_yaxis(series_name=\"y2线\",y_axis=population1.head()['人口数(人)'], is_smooth=True)\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"中国养老社保人数折线图\",\n",
    "                                               subtitle=\"数据表明，2010至2020年广东人口增长了2千多万，黑龙江人口负增长500多万。\\n进一步说明了人口向经济发达区域、城市群进一步集聚。\",\n",
    "                                               title_textstyle_opts=opts.TextStyleOpts(font_size=25,), \n",
    "                                               pos_left=\"center\", pos_top=\"0\",),\n",
    "                     \n",
    "                     legend_opts=opts.LegendOpts(orient=\"vertical\", pos_top=\"35%\", pos_left=\"90%\"))\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(is_show=False))\n",
    "#     .render('html/养老社保情况.html')\n",
    ")\n",
    "line.render_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1d9975d6",
   "metadata": {},
   "source": [
    "### 漏斗图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "b24b9893",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"b553d0e8a0454e028d935fef9e832cda\" style=\"width:1000px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_b553d0e8a0454e028d935fef9e832cda = echarts.init(\n",
       "                    document.getElementById('b553d0e8a0454e028d935fef9e832cda'), 'white', {renderer: 'canvas'});\n",
       "                var option_b553d0e8a0454e028d935fef9e832cda = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"funnel\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"2012\\u5e74\",\n",
       "                    \"value\": 48369.5\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2013\\u5e74\",\n",
       "                    \"value\": 49750.1\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2014\\u5e74\",\n",
       "                    \"value\": 50107.5\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2015\\u5e74\",\n",
       "                    \"value\": 50472.2\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2016\\u5e74\",\n",
       "                    \"value\": 50847.1\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2017\\u5e74\",\n",
       "                    \"value\": 51255.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2018\\u5e74\",\n",
       "                    \"value\": 52391.7\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2019\\u5e74\",\n",
       "                    \"value\": 53266.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2020\\u5e74\",\n",
       "                    \"value\": 54243.8\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"2021\\u5e74\",\n",
       "                    \"value\": 54797.0\n",
       "                }\n",
       "            ],\n",
       "            \"sort\": \"descending\",\n",
       "            \"gap\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"inside\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"formatter\": \"{a} <br/>{b} : {c}%\",\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"itemStyle\": {\n",
       "                \"borderColor\": \"#fff\",\n",
       "                \"borderWidth\": 1\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"2015\\u5e74\",\n",
       "                \"2012\\u5e74\",\n",
       "                \"2013\\u5e74\",\n",
       "                \"2019\\u5e74\",\n",
       "                \"2018\\u5e74\",\n",
       "                \"2017\\u5e74\",\n",
       "                \"2021\\u5e74\",\n",
       "                \"2020\\u5e74\",\n",
       "                \"2016\\u5e74\",\n",
       "                \"2014\\u5e74\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"2012\\u5e74\": true,\n",
       "                \"2013\\u5e74\": true,\n",
       "                \"2014\\u5e74\": true,\n",
       "                \"2015\\u5e74\": true,\n",
       "                \"2016\\u5e74\": true,\n",
       "                \"2017\\u5e74\": true,\n",
       "                \"2018\\u5e74\": true,\n",
       "                \"2019\\u5e74\": true,\n",
       "                \"2020\\u5e74\": true,\n",
       "                \"2021\\u5e74\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6f0f\\u6597\\u56fe\",\n",
       "            \"subtext\": \"\\u7eaf\\u5c5e\\u865a\\u6784\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_b553d0e8a0454e028d935fef9e832cda.setOption(option_b553d0e8a0454e028d935fef9e832cda);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be569c910>"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Funnel\n",
    "#xy轴数据\n",
    "x=shebao['指标']\n",
    "x1=list(x)\n",
    "\n",
    "y=shebao['城乡居民社会养老保险参保人数(万人)']\n",
    "y1=list(y)\n",
    "# x_data = [\"展现\", \"点击\", \"访问\", \"咨询\", \"订单\"]\n",
    "# y_data = [100, 80, 60, 40, 20]\n",
    "\n",
    "data = [[x1[i], y1[i]] for i in range(len(x1))]\n",
    "\n",
    "(\n",
    "    Funnel(init_opts=opts.InitOpts(width=\"1000px\", height=\"500px\"))\n",
    "    .add(\n",
    "        series_name=\"\",\n",
    "        data_pair=data,\n",
    "        gap=2,\n",
    "        tooltip_opts=opts.TooltipOpts(trigger=\"item\", formatter=\"{a} <br/>{b} : {c}%\"),\n",
    "        label_opts=opts.LabelOpts(is_show=True, position=\"inside\"),\n",
    "        itemstyle_opts=opts.ItemStyleOpts(border_color=\"#fff\", border_width=1),\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"漏斗图\", subtitle=\"纯属虚构\"))\n",
    "#     .render(\"funnel_chart.html\")\n",
    "   .render_notebook()\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "0c5c8e26",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'fangshi' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-38-8681f5e48339>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0mpyecharts\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcharts\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mFunnel\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[1;31m#xy轴数据\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[0mx\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mfangshi\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"喜欢的养老方式\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      5\u001b[0m \u001b[0mx1\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mlist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'fangshi' is not defined"
     ]
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Funnel\n",
    "#xy轴数据\n",
    "x=fangshi[\"喜欢的养老方式\"]\n",
    "x1=list(x)\n",
    "\n",
    "y=fangshi[\"合计\"]\n",
    "y1=list(y)\n",
    "# x_data = [\"展现\", \"点击\", \"访问\", \"咨询\", \"订单\"]\n",
    "# y_data = [100, 80, 60, 40, 20]\n",
    "\n",
    "data = [[x1[i], y1[i]] for i in range(len(x1))]\n",
    "\n",
    "(\n",
    "    Funnel(init_opts=opts.InitOpts(width=\"1000px\", height=\"500px\"))\n",
    "    .add(\n",
    "        series_name=\"\",\n",
    "        data_pair=data,\n",
    "        gap=2,\n",
    "        tooltip_opts=opts.TooltipOpts(trigger=\"item\", formatter=\"{a} <br/>{b} : {c}%\"),\n",
    "        label_opts=opts.LabelOpts(is_show=True, position=\"inside\"),\n",
    "        itemstyle_opts=opts.ItemStyleOpts(border_color=\"#fff\", border_width=1),\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"漏斗图\", subtitle=\"纯属虚构\"))\n",
    "#     .render(\"funnel_chart.html\")\n",
    "   .render_notebook()\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "04d91c0e",
   "metadata": {},
   "source": [
    "## 广东省各市基本养老保险"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 326,
   "id": "f220ff7e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>城市</th>\n",
       "      <th>基本养老保险(万元)</th>\n",
       "      <th>基金征缴率</th>\n",
       "      <th>失业保险(万元)</th>\n",
       "      <th>基金征缴率.1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>深圳市</td>\n",
       "      <td>5363531</td>\n",
       "      <td>99.853159</td>\n",
       "      <td>534106</td>\n",
       "      <td>99.427136</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>广州市</td>\n",
       "      <td>3354970</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>275611</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>中山市</td>\n",
       "      <td>834511</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>40166</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>珠海市</td>\n",
       "      <td>625518</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>52633</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>江门市</td>\n",
       "      <td>600201</td>\n",
       "      <td>98.431210</td>\n",
       "      <td>29839</td>\n",
       "      <td>99.079428</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>惠州市</td>\n",
       "      <td>531906</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>19283</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>汕头市</td>\n",
       "      <td>328519</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>26686</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>湛江市</td>\n",
       "      <td>317597</td>\n",
       "      <td>97.886560</td>\n",
       "      <td>16488</td>\n",
       "      <td>99.035253</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>茂名市</td>\n",
       "      <td>261929</td>\n",
       "      <td>96.001056</td>\n",
       "      <td>17367</td>\n",
       "      <td>98.302029</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>肇庆市</td>\n",
       "      <td>252590</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>17369</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>清远市</td>\n",
       "      <td>249045</td>\n",
       "      <td>99.962670</td>\n",
       "      <td>15990</td>\n",
       "      <td>99.993659</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>韶关市</td>\n",
       "      <td>238925</td>\n",
       "      <td>97.160915</td>\n",
       "      <td>14781</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>梅州市</td>\n",
       "      <td>235298</td>\n",
       "      <td>100.000000</td>\n",
       "      <td>9439</td>\n",
       "      <td>100.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>揭阳市</td>\n",
       "      <td>212710</td>\n",
       "      <td>82.091349</td>\n",
       "      <td>4883</td>\n",
       "      <td>99.957806</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>汕尾市</td>\n",
       "      <td>98282</td>\n",
       "      <td>57.878662</td>\n",
       "      <td>4953</td>\n",
       "      <td>77.438137</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     城市  基本养老保险(万元)       基金征缴率  失业保险(万元)     基金征缴率.1\n",
       "0   深圳市     5363531   99.853159    534106   99.427136\n",
       "1   广州市     3354970  100.000000    275611  100.000000\n",
       "2   中山市      834511  100.000000     40166  100.000000\n",
       "3   珠海市      625518  100.000000     52633  100.000000\n",
       "4   江门市      600201   98.431210     29839   99.079428\n",
       "5   惠州市      531906  100.000000     19283  100.000000\n",
       "6   汕头市      328519  100.000000     26686  100.000000\n",
       "7   湛江市      317597   97.886560     16488   99.035253\n",
       "8   茂名市      261929   96.001056     17367   98.302029\n",
       "9   肇庆市      252590  100.000000     17369  100.000000\n",
       "10  清远市      249045   99.962670     15990   99.993659\n",
       "11  韶关市      238925   97.160915     14781  100.000000\n",
       "12  梅州市      235298  100.000000      9439  100.000000\n",
       "13  揭阳市      212710   82.091349      4883   99.957806\n",
       "14  汕尾市       98282   57.878662      4953   77.438137"
      ]
     },
     "execution_count": 326,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "guangdong=pd.read_excel('data/广东省各市社会基本养老.xlsx',sheet_name='广东省各市社会基本养老')\n",
    "guangdong"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3d01d857",
   "metadata": {},
   "source": [
    "### 地图（√）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 327,
   "id": "b55666c1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[('深圳市', 5363531), ('广州市', 3354970), ('中山市', 834511), ('珠海市', 625518), ('江门市', 600201), ('惠州市', 531906), ('汕头市', 328519), ('湛江市', 317597), ('茂名市', 261929), ('肇庆市', 252590), ('清远市', 249045), ('韶关市', 238925), ('梅州市', 235298), ('揭阳市', 212710), ('汕尾市', 98282)]\n",
      "\n",
      "[('深圳市', 5363531), ('广州市', 3354970), ('中山市', 834511), ('珠海市', 625518), ('江门市', 600201), ('惠州市', 531906), ('汕头市', 328519), ('湛江市', 317597), ('茂名市', 261929), ('肇庆市', 252590), ('清远市', 249045), ('韶关市', 238925), ('梅州市', 235298), ('揭阳市', 212710), ('汕尾市', 98282)]\n",
      "\n",
      "[['深圳市', 5363531], ['广州市', 3354970], ['中山市', 834511], ['珠海市', 625518], ['江门市', 600201], ['惠州市', 531906], ['汕头市', 328519], ['湛江市', 317597], ['茂名市', 261929], ['肇庆市', 252590], ['清远市', 249045], ['韶关市', 238925], ['梅州市', 235298], ['揭阳市', 212710], ['汕尾市', 98282]]\n",
      "\n",
      "[['深圳市', 5363531], ['广州市', 3354970], ['中山市', 834511], ['珠海市', 625518], ['江门市', 600201], ['惠州市', 531906], ['汕头市', 328519], ['湛江市', 317597], ['茂名市', 261929], ['肇庆市', 252590], ['清远市', 249045], ['韶关市', 238925], ['梅州市', 235298], ['揭阳市', 212710], ['汕尾市', 98282]]\n"
     ]
    }
   ],
   "source": [
    "data=pd.read_excel('data/广东省各市社会基本养老.xlsx',sheet_name='广东省各市社会基本养老')\n",
    "city=data.iloc[:,0]\n",
    "population=data.iloc[:,1]\n",
    "z1=[i for i in zip(city,population)]\n",
    "z2=list(zip(city,population))\n",
    "z3=[list(i) for i in zip(city,population)]\n",
    "z4=data[['城市','基本养老保险(万元)']].values.tolist()\n",
    "print(z1,z2,z3,z4,sep='\\n\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 331,
   "id": "861cefd2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min', '广东':'https://assets.pyecharts.org/assets/maps/guangdong'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"a9589aad17ff41548b17bbf92bd7a441\" style=\"width:1200px; height:600px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts', '广东'], function(echarts) {\n",
       "                var chart_a9589aad17ff41548b17bbf92bd7a441 = echarts.init(\n",
       "                    document.getElementById('a9589aad17ff41548b17bbf92bd7a441'), 'white', {renderer: 'canvas'});\n",
       "                var option_a9589aad17ff41548b17bbf92bd7a441 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"map\",\n",
       "            \"name\": \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5e02\\u57fa\\u672c\\u517b\\u8001\\u4fdd\\u9669\",\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"mapType\": \"\\u5e7f\\u4e1c\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u6df1\\u5733\\u5e02\",\n",
       "                    \"value\": 5363531\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e7f\\u5dde\\u5e02\",\n",
       "                    \"value\": 3354970\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u4e2d\\u5c71\\u5e02\",\n",
       "                    \"value\": 834511\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u73e0\\u6d77\\u5e02\",\n",
       "                    \"value\": 625518\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c5f\\u95e8\\u5e02\",\n",
       "                    \"value\": 600201\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u60e0\\u5dde\\u5e02\",\n",
       "                    \"value\": 531906\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c55\\u5934\\u5e02\",\n",
       "                    \"value\": 328519\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e5b\\u6c5f\\u5e02\",\n",
       "                    \"value\": 317597\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8302\\u540d\\u5e02\",\n",
       "                    \"value\": 261929\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8087\\u5e86\\u5e02\",\n",
       "                    \"value\": 252590\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6e05\\u8fdc\\u5e02\",\n",
       "                    \"value\": 249045\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u97f6\\u5173\\u5e02\",\n",
       "                    \"value\": 238925\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6885\\u5dde\\u5e02\",\n",
       "                    \"value\": 235298\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u63ed\\u9633\\u5e02\",\n",
       "                    \"value\": 212710\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6c55\\u5c3e\\u5e02\",\n",
       "                    \"value\": 98282\n",
       "                }\n",
       "            ],\n",
       "            \"roam\": true,\n",
       "            \"aspectScale\": 0.75,\n",
       "            \"nameProperty\": \"name\",\n",
       "            \"selectedMode\": false,\n",
       "            \"zoom\": 1,\n",
       "            \"mapValueCalculation\": \"sum\",\n",
       "            \"showLegendSymbol\": true,\n",
       "            \"emphasis\": {},\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5e02\\u57fa\\u672c\\u517b\\u8001\\u4fdd\\u9669\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5e02\\u57fa\\u672c\\u517b\\u8001\\u4fdd\\u9669\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5e7f\\u4e1c\\u7701\\u5404\\u5e02\\u57fa\\u672c\\u517b\\u8001\\u4fdd\\u9669\",\n",
       "            \"subtext\": \"\\u6570\\u636e\\u6765\\u6e90\\uff1a\\u5e7f\\u4e1c\\u7edf\\u8ba1\\u5e74\\u9274\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"piecewise\",\n",
       "        \"min\": 0,\n",
       "        \"max\": 5363531,\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"lightskyblue\",\n",
       "                \"yellow\",\n",
       "                \"orangered\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 14,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "                chart_a9589aad17ff41548b17bbf92bd7a441.setOption(option_a9589aad17ff41548b17bbf92bd7a441);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1afad243730>"
      ]
     },
     "execution_count": 331,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "map=Map(init_opts=opts.InitOpts(width=\"1200px\",height='600px'))\n",
    "map.add('广东省各市基本养老保险',data_pair=z3,maptype='广东',is_map_symbol_show=True)\n",
    "map.set_series_opts(label_opts=opts.LabelOpts(is_show=True))\n",
    "map.set_global_opts(title_opts=opts.TitleOpts(title='广东省各市基本养老保险',subtitle='数据来源：广东统计年鉴'),\n",
    "    visualmap_opts=opts.VisualMapOpts(max_=5363531,is_piecewise=True,range_color=['lightskyblue','yellow','orangered']))\n",
    "map.render_notebook()\n",
    "# map.render('html/广东省地图.html') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 320,
   "id": "3be426bf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['深圳',\n",
       " '广州',\n",
       " '中山',\n",
       " '珠海',\n",
       " '江门',\n",
       " '惠州',\n",
       " '汕头',\n",
       " '湛江',\n",
       " '茂名',\n",
       " '肇庆',\n",
       " '清远',\n",
       " '韶关',\n",
       " '梅州',\n",
       " '揭阳',\n",
       " '汕尾']"
      ]
     },
     "execution_count": 320,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x=guangdong['城市']\n",
    "x_data=list(x)\n",
    "x_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 321,
   "id": "35f2fd92",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[5363531,\n",
       " 3354970,\n",
       " 834511,\n",
       " 625518,\n",
       " 600201,\n",
       " 531906,\n",
       " 328519,\n",
       " 317597,\n",
       " 261929,\n",
       " 252590,\n",
       " 249045,\n",
       " 238925,\n",
       " 235298,\n",
       " 212710,\n",
       " 98282]"
      ]
     },
     "execution_count": 321,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y=guangdong['基本养老保险(万元)']\n",
    "y_data=list(y)\n",
    "y_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 324,
   "id": "d824e006",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyecharts.faker import Faker\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Map\n",
    "\n",
    "# 用于测试的例子，部分取自 Faker ，也就是 from pyecharts.faker import Faker\n",
    "provinces = [\"广东\", \"北京\", \"上海\", \"辽宁\", \"湖南\", \"四川\", \"西藏\"]\n",
    "guangdong_city = [\"汕头市\", \"汕尾市\", \"揭阳市\", \"阳江市\", \"肇庆市\", \"广州市\", \"惠州市\"]\n",
    "country = [\"China\", \"Canada\", \"Brazil\", \"Russia\", \"United States\", \"Africa\", \"Germany\"]\n",
    "value = [300, 100, 2000, 800, 10000, 400, 5000]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 325,
   "id": "a21f7d24",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 显示广东省地图\n",
    "def map_guangdong() -> Map:\n",
    "    c = (\n",
    "        Map()\n",
    "        .add(\"\", [list(z) for z in zip(guangdong_city, value)], \"广东\")\n",
    "        .set_global_opts(\n",
    "            title_opts=opts.TitleOpts(title=\"广东地图\"),\n",
    "            visualmap_opts=opts.VisualMapOpts(max_=2000),\n",
    "        )\n",
    "    )\n",
    "    return c\n",
    "if __name__ == '__main__':\n",
    "    gd = map_guangdong()\n",
    "    gd.render(path=\"test_map_1.html\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "06534f62",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "5cc573a9",
   "metadata": {},
   "source": [
    "\n",
    "### 漏斗图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "47b4f77c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"e055a2d5d49a45bcb7cd4eb2041a1bf0\" style=\"width:1000px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_e055a2d5d49a45bcb7cd4eb2041a1bf0 = echarts.init(\n",
       "                    document.getElementById('e055a2d5d49a45bcb7cd4eb2041a1bf0'), 'white', {renderer: 'canvas'});\n",
       "                var option_e055a2d5d49a45bcb7cd4eb2041a1bf0 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"funnel\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u4e0e\\u5b50\\u5973\\u4e00\\u8d77\\u5c45\\u4f4f\",\n",
       "                    \"value\": 42.3\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u6700\\u597d\\u4f4f\\u5728\\u9644\\u8fd1\",\n",
       "                    \"value\": 39.3\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u5728\\u4e0d\\u5728\\u9644\\u8fd1\",\n",
       "                    \"value\": 16.3\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u656c\\u8001\\u9662\\u3001\\u798f\\u5229\\u9662\",\n",
       "                    \"value\": 1.3\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5176\\u4ed6\",\n",
       "                    \"value\": 0.6\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6751\\u91cc\\u7684\\u65e5\\u6258\\u6240\",\n",
       "                    \"value\": 0.2\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5546\\u4e1a\\u6027\\u8001\\u5e74\\u516c\\u5bd3\",\n",
       "                    \"value\": 0.1\n",
       "                }\n",
       "            ],\n",
       "            \"sort\": \"descending\",\n",
       "            \"gap\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"inside\",\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"tooltip\": {\n",
       "                \"show\": true,\n",
       "                \"trigger\": \"item\",\n",
       "                \"triggerOn\": \"mousemove|click\",\n",
       "                \"axisPointer\": {\n",
       "                    \"type\": \"line\"\n",
       "                },\n",
       "                \"showContent\": true,\n",
       "                \"alwaysShowContent\": false,\n",
       "                \"showDelay\": 0,\n",
       "                \"hideDelay\": 100,\n",
       "                \"formatter\": \"{a} <br/>{b} : {c}%\",\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 14\n",
       "                },\n",
       "                \"borderWidth\": 0,\n",
       "                \"padding\": 5\n",
       "            },\n",
       "            \"itemStyle\": {\n",
       "                \"borderColor\": \"#fff\",\n",
       "                \"borderWidth\": 1\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u6751\\u91cc\\u7684\\u65e5\\u6258\\u6240\",\n",
       "                \"\\u5546\\u4e1a\\u6027\\u8001\\u5e74\\u516c\\u5bd3\",\n",
       "                \"\\u5176\\u4ed6\",\n",
       "                \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u6700\\u597d\\u4f4f\\u5728\\u9644\\u8fd1\",\n",
       "                \"\\u656c\\u8001\\u9662\\u3001\\u798f\\u5229\\u9662\",\n",
       "                \"\\u4e0e\\u5b50\\u5973\\u4e00\\u8d77\\u5c45\\u4f4f\",\n",
       "                \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u5728\\u4e0d\\u5728\\u9644\\u8fd1\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u4e0e\\u5b50\\u5973\\u4e00\\u8d77\\u5c45\\u4f4f\": true,\n",
       "                \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u6700\\u597d\\u4f4f\\u5728\\u9644\\u8fd1\": true,\n",
       "                \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u5728\\u4e0d\\u5728\\u9644\\u8fd1\": true,\n",
       "                \"\\u656c\\u8001\\u9662\\u3001\\u798f\\u5229\\u9662\": true,\n",
       "                \"\\u5176\\u4ed6\": true,\n",
       "                \"\\u6751\\u91cc\\u7684\\u65e5\\u6258\\u6240\": true,\n",
       "                \"\\u5546\\u4e1a\\u6027\\u8001\\u5e74\\u516c\\u5bd3\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6f0f\\u6597\\u56fe\",\n",
       "            \"subtext\": \"\\u7eaf\\u5c5e\\u865a\\u6784\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_e055a2d5d49a45bcb7cd4eb2041a1bf0.setOption(option_e055a2d5d49a45bcb7cd4eb2041a1bf0);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be56bc2b0>"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pyecharts.options as opts\n",
    "from pyecharts.charts import Funnel\n",
    "#xy轴数据\n",
    "x=fangshi[\"喜欢的养老方式\"]\n",
    "x1=list(x)\n",
    "\n",
    "y=fangshi[\"合计\"]\n",
    "y1=list(y)\n",
    "# x_data = [\"展现\", \"点击\", \"访问\", \"咨询\", \"订单\"]\n",
    "# y_data = [100, 80, 60, 40, 20]\n",
    "\n",
    "data = [[x1[i], y1[i]] for i in range(len(x1))]\n",
    "\n",
    "(\n",
    "    Funnel(init_opts=opts.InitOpts(width=\"1000px\", height=\"500px\"))\n",
    "    .add(\n",
    "        series_name=\"\",\n",
    "        data_pair=data,\n",
    "        gap=2,\n",
    "        tooltip_opts=opts.TooltipOpts(trigger=\"item\", formatter=\"{a} <br/>{b} : {c}%\"),\n",
    "        label_opts=opts.LabelOpts(is_show=True, position=\"inside\"),\n",
    "        itemstyle_opts=opts.ItemStyleOpts(border_color=\"#fff\", border_width=1),\n",
    "    )\n",
    "    .set_global_opts(title_opts=opts.TitleOpts(title=\"漏斗图\", subtitle=\"纯属虚构\"))\n",
    "#     .render(\"funnel_chart.html\")\n",
    "   .render_notebook()\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3d59bb33",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "7b81e1cc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"b650a1dc72254e49b7ab91d0dcdc774b\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_b650a1dc72254e49b7ab91d0dcdc774b = echarts.init(\n",
       "                    document.getElementById('b650a1dc72254e49b7ab91d0dcdc774b'), 'white', {renderer: 'canvas'});\n",
       "                var option_b650a1dc72254e49b7ab91d0dcdc774b = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"clockwise\": true,\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u4e0e\\u5b50\\u5973\\u4e00\\u8d77\\u5c45\\u4f4f\",\n",
       "                    \"value\": 42.3\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u6700\\u597d\\u4f4f\\u5728\\u9644\\u8fd1\",\n",
       "                    \"value\": 39.3\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u5728\\u4e0d\\u5728\\u9644\\u8fd1\",\n",
       "                    \"value\": 16.3\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u656c\\u8001\\u9662\\u3001\\u798f\\u5229\\u9662\",\n",
       "                    \"value\": 1.3\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5176\\u4ed6\",\n",
       "                    \"value\": 0.6\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6751\\u91cc\\u7684\\u65e5\\u6258\\u6240\",\n",
       "                    \"value\": 0.2\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5546\\u4e1a\\u6027\\u8001\\u5e74\\u516c\\u5bd3\",\n",
       "                    \"value\": 0.1\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"0%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"top\",\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{b}: {c}\"\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u4e0e\\u5b50\\u5973\\u4e00\\u8d77\\u5c45\\u4f4f\",\n",
       "                \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u6700\\u597d\\u4f4f\\u5728\\u9644\\u8fd1\",\n",
       "                \"\\u72ec\\u5c45\\uff08\\u6216\\u4e0e\\u914d\\u5076\\u4f4f\\uff09\\uff0c\\u5b50\\u5973\\u5728\\u4e0d\\u5728\\u9644\\u8fd1\",\n",
       "                \"\\u656c\\u8001\\u9662\\u3001\\u798f\\u5229\\u9662\",\n",
       "                \"\\u5176\\u4ed6\",\n",
       "                \"\\u6751\\u91cc\\u7684\\u65e5\\u6258\\u6240\",\n",
       "                \"\\u5546\\u4e1a\\u6027\\u8001\\u5e74\\u516c\\u5bd3\"\n",
       "            ],\n",
       "            \"selected\": {}\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    }\n",
       "};\n",
       "                chart_b650a1dc72254e49b7ab91d0dcdc774b.setOption(option_b650a1dc72254e49b7ab91d0dcdc774b);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be556f730>"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x=fangshi[\"喜欢的养老方式\"]\n",
    "x_data=list(x)\n",
    "\n",
    "y=fangshi[\"合计\"]\n",
    "y_data=list(y)\n",
    "c = (\n",
    "    Pie()\n",
    "    .add(\"\", [list(z) for z in zip(x_data, y_data)])   # zip函数两个部分组合在一起list(zip(x,y))-----> [(x,y)]\n",
    "#     .set_global_opts(title_opts=opts.TitleOpts(title=\"三大湾区总估值\"))  # 标题\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(formatter=\"{b}: {c}\"))  # 数据标签设置\n",
    ")\n",
    "\n",
    "c.render_notebook()\n",
    "# c.render('html/老龄人口比重.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6708e330",
   "metadata": {},
   "source": [
    "# 养老从业者"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cd51688c",
   "metadata": {},
   "source": [
    "## 养老员工占比"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "9e1d01eb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>年份</th>\n",
       "      <th>养老职工数占比(%)</th>\n",
       "      <th>缺口占比(%)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2012</td>\n",
       "      <td>30</td>\n",
       "      <td>70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2013</td>\n",
       "      <td>32</td>\n",
       "      <td>68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2014</td>\n",
       "      <td>33</td>\n",
       "      <td>67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2015</td>\n",
       "      <td>35</td>\n",
       "      <td>65</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2016</td>\n",
       "      <td>31</td>\n",
       "      <td>69</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2017</td>\n",
       "      <td>28</td>\n",
       "      <td>72</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2018</td>\n",
       "      <td>29</td>\n",
       "      <td>71</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2019</td>\n",
       "      <td>31</td>\n",
       "      <td>69</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     年份  养老职工数占比(%)  缺口占比(%)\n",
       "0  2012          30       70\n",
       "1  2013          32       68\n",
       "2  2014          33       67\n",
       "3  2015          35       65\n",
       "4  2016          31       69\n",
       "5  2017          28       72\n",
       "6  2018          29       71\n",
       "7  2019          31       69"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "yuangong=pd.read_excel('data/养老机构员工数量.xlsx',\n",
    "                        sheet_name='养老机构员工数量'\n",
    "                     )\n",
    "yuangong"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "19fe4f5d",
   "metadata": {},
   "source": [
    "### 堆叠图（√）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "09b81c95",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "from pyecharts.charts import Bar\n",
    "from pyecharts import options as opts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "46d72499",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"416334387f514ba4bd4b4e67e490ea94\" style=\"width:900px; height:600px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_416334387f514ba4bd4b4e67e490ea94 = echarts.init(\n",
       "                    document.getElementById('416334387f514ba4bd4b4e67e490ea94'), 'white', {renderer: 'canvas'});\n",
       "                var option_416334387f514ba4bd4b4e67e490ea94 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"color\": [\n",
       "        \"DarkCyan\",\n",
       "        \"Turquoise\",\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u73b0\\u6709\\u804c\\u5de5\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                30,\n",
       "                32,\n",
       "                33,\n",
       "                35,\n",
       "                31,\n",
       "                28,\n",
       "                29,\n",
       "                31\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"stack\": \"stack1\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"inside\",\n",
       "                \"color\": \"white\",\n",
       "                \"margin\": 8,\n",
       "                \"fontSize\": 10\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u5458\\u5de5\\u7f3a\\u53e3\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"data\": [\n",
       "                70,\n",
       "                68,\n",
       "                67,\n",
       "                65,\n",
       "                69,\n",
       "                72,\n",
       "                71,\n",
       "                69\n",
       "            ],\n",
       "            \"showBackground\": false,\n",
       "            \"stack\": \"stack1\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"position\": \"inside\",\n",
       "                \"color\": \"white\",\n",
       "                \"margin\": 8,\n",
       "                \"fontSize\": 10\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u73b0\\u6709\\u804c\\u5de5\",\n",
       "                \"\\u5458\\u5de5\\u7f3a\\u53e3\"\n",
       "            ],\n",
       "            \"selected\": {\n",
       "                \"\\u73b0\\u6709\\u804c\\u5de5\": true,\n",
       "                \"\\u5458\\u5de5\\u7f3a\\u53e3\": true\n",
       "            },\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                2012,\n",
       "                2013,\n",
       "                2014,\n",
       "                2015,\n",
       "                2016,\n",
       "                2017,\n",
       "                2018,\n",
       "                2019\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": false,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u517b\\u8001\\u4ece\\u4e1a\\u4eba\\u5458\\uff08\\u5355\\u4f4d\\uff1a%\\uff09\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"dataZoom\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"slider\",\n",
       "        \"realtime\": true,\n",
       "        \"start\": 20,\n",
       "        \"end\": 80,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"zoomLock\": false,\n",
       "        \"filterMode\": \"filter\"\n",
       "    }\n",
       "};\n",
       "                chart_416334387f514ba4bd4b4e67e490ea94.setOption(option_416334387f514ba4bd4b4e67e490ea94);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x26be2f7e400>"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stack_bar = (\n",
    "    Bar(init_opts=opts.InitOpts(width=\"900px\", height=\"600px\"))\n",
    "    .add_xaxis(yuangong[\"年份\"].tolist())\n",
    "    .add_yaxis(\"现有职工\", yuangong[\"养老职工数占比(%)\"].tolist(), stack=\"stack1\", color=\"Turquoise\")\n",
    "    .add_yaxis(\"员工缺口\", yuangong[\"缺口占比(%)\"].tolist(), stack=\"stack1\",color=\"DarkCyan\")\n",
    "     .set_global_opts(title_opts=opts.TitleOpts(title=\"养老从业人员（单位：%）\"),\n",
    "                     datazoom_opts=opts.DataZoomOpts(type_=\"slider\"))\n",
    "    # 在系列设置中设置标签属性\n",
    "    .set_series_opts(\n",
    "        label_opts=opts.LabelOpts(position=\"inside\", color=\"white\", font_size=10)\n",
    "    )\n",
    ")\n",
    "\n",
    "stack_bar.render_notebook()\n",
    "# stack_bar.render('html/养老从业人员.html')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "59b838e9",
   "metadata": {},
   "source": [
    "## 失能老人服务提供者"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 207,
   "id": "fa053a3d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>服务提供者</th>\n",
       "      <th>中度失能老人(%)</th>\n",
       "      <th>重度失能老人(%)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>子女</td>\n",
       "      <td>40.0</td>\n",
       "      <td>35.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>第三方机构</td>\n",
       "      <td>25.4</td>\n",
       "      <td>32.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>老伴</td>\n",
       "      <td>22.1</td>\n",
       "      <td>18.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>保姆</td>\n",
       "      <td>10.8</td>\n",
       "      <td>12.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>其它</td>\n",
       "      <td>1.7</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   服务提供者  中度失能老人(%)  重度失能老人(%)\n",
       "0     子女       40.0       35.4\n",
       "1  第三方机构       25.4       32.6\n",
       "2     老伴       22.1       18.4\n",
       "3     保姆       10.8       12.6\n",
       "4     其它        1.7        1.0"
      ]
     },
     "execution_count": 207,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fuwu=pd.read_excel('data/失能老人服务提供者.xlsx',\n",
    "                        sheet_name='数据'\n",
    "                     )\n",
    "fuwu"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "de0b2ece",
   "metadata": {},
   "source": [
    "### 双柱状图（√）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 206,
   "id": "f03d7568",
   "metadata": {},
   "outputs": [],
   "source": [
    "bar = (\n",
    "    Bar(\n",
    "#         init_opts=opts.InitOpts(           # 初始配置项\n",
    "#             theme=ThemeType.MACARONS,\n",
    "#             animation_opts=opts.AnimationOpts(\n",
    "#                 animation_delay=1000, animation_easing=\"cubicOut\"   # 初始动画延迟和缓动效果\n",
    "#             ))\n",
    "        )\n",
    "    # 选取表格中前五个数据\n",
    "    .add_xaxis(xaxis_data=fuwu['服务提供者'].tolist())      # x轴\n",
    "    .add_yaxis(series_name=\"中度失能老人\", y_axis=fuwu['中度失能老人(%)'].tolist(),color=[\"#336699\"])       # y轴\n",
    "    .add_yaxis(series_name=\"重度失能老人\", y_axis=fuwu['重度失能老人(%)'].tolist(),color=[\"#99CC33\"])       # y轴\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(title='失能老人服务提供者分布',\n",
    "                                  subtitle='', \n",
    "                                  title_textstyle_opts=opts.TextStyleOpts(), pos_left=\"center\", pos_top=\"0\",\n",
    "                                  ),\n",
    "        legend_opts=opts.LegendOpts(orient=\"vertical\", pos_top=\"35%\", pos_right=\"0%\"),\n",
    "        xaxis_opts=opts.AxisOpts(name='服务者', axislabel_opts=opts.LabelOpts(rotate=0)),  # 设置x名称和Label rotate解决标签名字过长使用\n",
    "        yaxis_opts=opts.AxisOpts(name='')\n",
    "          )\n",
    "    .render(\"html/失能老人服务提供者.html\")\n",
    "  \n",
    ")\n",
    "        \n",
    "#  bar.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cb0a4d90",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "384px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
